/* -*- coding: utf-8 -*- * * 1142.cc: No.1142 XOR と XOR - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 200000; const int MAX_K = 1 << 10; // = 1024 const int MOD = 1000000007; /* typedef */ typedef long long ll; typedef vector vi; /* global variables */ int ass[MAX_N + 1], bss[MAX_N + 1]; vi va[MAX_K], vb[MAX_K]; int cas[MAX_K], cbs[MAX_K]; /* subroutines */ inline int pmod(int a, int b) { return (ll)a * b % MOD; } inline void addmod(int &a, int b) { a = (a + b) % MOD; } void calc(vi v[], int cs[]) { for (int bits0 = 0; bits0 < MAX_K; bits0++) { vi &v0 = v[bits0]; int n0 = v0.size(); addmod(cs[0], (ll)n0 * (n0 - 1) / 2 % MOD); for (int bits1 = bits0 + 1; bits1 < MAX_K; bits1++) addmod(cs[bits0 ^ bits1], pmod(n0, v[bits1].size())); } } /* main */ int main() { int n, m, k; scanf("%d%d%d", &n, &m, &k); for (int i = 0; i < n; i++) { int a; scanf("%d", &a); ass[i + 1] = ass[i] ^ a; } for (int i = 0; i < m; i++) { int b; scanf("%d", &b); bss[i + 1] = bss[i] ^ b; } for (int i = 0; i <= n; i++) va[ass[i]].push_back(i); for (int i = 0; i <= m; i++) vb[bss[i]].push_back(i); calc(va, cas); calc(vb, cbs); int sum = 0; for (int bits = 0; bits < MAX_K; bits++) addmod(sum, pmod(cas[bits], cbs[k ^ bits])); printf("%d\n", sum); return 0; }