//#define _GLIBCXX_DEBUG #include #define rep(i, n) for(int i=0; i; using vs = vector; using vi = vector; using vvi = vector; template using PQ = priority_queue; template using PQG = priority_queue, greater >; const int INF = 100010001; const ll LINF = (ll)INF*INF*10; template inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);} template inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);} template istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second;} template ostream &operator<<(ostream &os, const pair &p) { return os << p.first << ' ' << p.second;} const int N = 2e5+10; const int X = 1024; //head int n, m, k; int a[N], b[N]; int suma[N+1], sumb[N+1]; int cnta[X], cntb[X]; ll jja[X], jjb[X]; ll ans; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m >> k; rep(i, n) cin >> a[i]; rep(i, m) cin >> b[i]; rep(i, n) suma[i+1] = suma[i] ^ a[i]; rep(i, m) sumb[i+1] = sumb[i] ^ b[i]; rep(i, n+1) cnta[suma[i]]++; rep(i, m+1) cntb[sumb[i]]++; rep(i, X) rep(j, X) { if(i == j) { jja[0] += ll(cnta[i])*(cnta[i]-1); } else { jja[i^j] += ll(cnta[i])*cnta[j]; } } rep(i, X) rep(j, X) { if(i == j) { jjb[0] += ll(cntb[i])*(cntb[i]-1); } else { jjb[i^j] += ll(cntb[i])*cntb[j]; } } rep(i, X) { ans += jja[i] * jjb[i^k]; } cout << ans/4 << endl; }