#include typedef long long int ll; constexpr int kN = int(2E5 + 10), kMod = int(1E9 + 7), kC = 1 << 10; int a[kN], b[kN]; ll ca[kN], cb[kN], sa[kN], sb[kN]; int main() { int n, m, k; ll ans = 0; scanf("%d%d%d", &n, &m, &k); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); for (int i = 1; i <= m; i++) scanf("%d", &b[i]); for (int i = 1; i <= n; i++) a[i] ^= a[i - 1]; for (int i = 1; i <= m; i++) b[i] ^= b[i - 1]; ca[0] = cb[0] = 1; for (int i = 1; i <= n; i++) ca[a[i]]++; for (int i = 1; i <= m; i++) cb[b[i]]++; for (int i = 0; i < kC; i++) for (int j = i + 1; j < kC; j++) sa[i ^ j] += ca[i] * ca[j] % kMod; for (int i = 0; i < kC; i++) for (int j = i + 1; j < kC; j++) sb[i ^ j] += cb[i] * cb[j] % kMod; for (int i = 0; i < kC; i++) sa[0] += (ca[i] * (ca[i] - 1) / 2) % kMod; for (int i = 0; i < kC; i++) sb[0] += (cb[i] * (cb[i] - 1) / 2) % kMod; for (int i = 0; i < kC; i++) sa[i] %= kMod; for (int i = 0; i < kC; i++) sb[i] %= kMod; for (int i = 0; i < kC; i++) ans += sa[i] * sb[i ^ k] % kMod; printf("%lld\n", ans % kMod); }