#include "bits/stdc++.h" using namespace std; // コンテスト中のみ //#define int long long #define ll long long #define rep(i,n) for(int i = 0; i < (n); i++) #define P pair #define ld long double ll INF = (1LL << 60); int mod = 1000000007; ll N, M, K; ll a[200010], b[200010]; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> N >> M >> K; rep(i, N)cin >> a[i]; rep(i, M)cin >> b[i]; vectorruia(N + 1), ruib(M + 1); rep(i, N) { ruia[i + 1] = ruia[i] ^ a[i]; } rep(i, M) { ruib[i + 1] = ruib[i] ^ b[i]; } vectorcnta(1 << 10), cntb(1 << 10); rep(i, N + 1)cnta[ruia[i]]++; rep(i, M + 1)cntb[ruib[i]]++; vectorc(1 << 10), d(1 << 10); rep(i, 1 << 10) { for (int j = i + 1; j < (1 << 10); j++) { c[i ^ j] += cnta[i] * cnta[j]; c[i^j] %= mod; d[i^j] += cntb[i] * cntb[j]; d[i^j] %= mod; } } rep(i, 1 << 10) { c[0] += (cnta[i] * (cnta[i] - 1)) / 2; c[0] %= mod; d[0] += (cntb[i] * (cntb[i] - 1)) / 2; d[0] %= mod; } ll ans = 0; rep(i, 1 << 10) { rep(j, 1 << 10) { if ((i^j) == K) { ans += c[i] * d[j]; ans %= mod; } } } cout << ans << endl; return 0; }