// 21:03 - 21:10 #include using namespace std; #define fi first #define se second #define all(x) x.begin(), x.end() #define lch (o << 1) #define rch (o << 1 | 1) typedef double db; typedef long long ll; typedef unsigned int ui; typedef pair pint; typedef tuple tint; const int N = 2e5 + 5; const int M = 1024; const int MOD = 1e9 + 7; const int INV2 = 500000004; const int INF = 0x3f3f3f3f; const ll INF_LL = 0x3f3f3f3f3f3f3f3f; int a[N], b[N]; int cnta[M], cntb[M]; void Cov(int x[]) { int tmp[M]; memset(tmp, 0, sizeof(tmp)); for (int i = 0; i < M; i++) for (int j = 0; j < M; j++) { int k = i ^ j; tmp[k] = (tmp[k] + 1LL * x[i] * x[j]) % MOD; } for (int i = 0; i < M; i++) x[i] = tmp[i]; } int main() { ios::sync_with_stdio(0); int n, m, k; cin >> n >> m >> k; cnta[0] = cntb[0] = 1; for (int i = 1; i <= n; i++) { cin >> a[i]; a[i] ^= a[i - 1]; cnta[a[i]]++; } for (int i = 1; i <= m; i++) { cin >> b[i]; b[i] ^= b[i - 1]; cntb[b[i]]++; } Cov(cnta); Cov(cntb); cnta[0] = (cnta[0] - n - 1 + MOD) % MOD; cntb[0] = (cntb[0] - m - 1 + MOD) % MOD; for (int i = 0; i < M; i++) { cnta[i] = 1LL * cnta[i] * INV2 % MOD; cntb[i] = 1LL * cntb[i] * INV2 % MOD; } ll ans = 0; for (int i = 0; i < M; i++) ans = (ans + 1LL * cnta[i] * cntb[i ^ k]) % MOD; ans = (ans % MOD + MOD) % MOD; cout << ans << endl; return 0; }