Z′ models for the LHCb and g-2 muon anomalies