#include using namespace std; typedef long long ll; #define pb push_back #define fi first #define se second typedef pair P; using VP = vector

; using VVP = vector; using VI = vector; using VVI = vector; using VVVI = vector; const int inf = 1e9 + 7; const ll INF = 1LL << 61; const ll mod = 1e9 + 7; template inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int i, j; int n, n2, k; cin >> n >> n2 >> k; int a[n], b[n2]; for (i = 0; i < n; i++) cin >> a[i]; for (i = 0; i < n2; i++) cin >> b[i]; int m = 1024; VI cnta(m, 0), cntb(m, 0); int p = 0; cnta[p]++; for (i = 0; i < n; i++) { p ^= a[i]; cnta[p]++; } p = 0; cntb[p]++; for (i = 0; i < n2; i++) { p ^= b[i]; cntb[p]++; } VI va(m, 0), vb(m, 0); for (i = 0; i < m; i++) { // if (cnta[i] > 0) cout << i << " " << cnta[i] << endl; for (j = i; j < m; j++) { if (i == j) va[i ^ j] += cnta[i] * (cnta[i] - 1) / 2; else { va[i ^ j] += cnta[i] * cnta[j]; va[i ^ j] %= mod; } } } for (i = 0; i < m; i++) { // if (va[i] > 0) cout << i << " " << va[i] << endl; } for (i = 0; i < m; i++) { for (j = i; j < m; j++) { if (i == j) vb[i ^ j] += cntb[i] * (cntb[i] - 1) / 2; else { vb[i ^ j] += cntb[i] * cntb[j]; vb[i ^ j] %= mod; } } } ll ans = 0; for (i = 0; i < m; i++) { ans += va[i] * vb[k ^ i]; ans %= mod; } cout << ans << endl; }