#include using namespace std; int main() { constexpr int64_t mod = 1000000007; int n, m, k; cin >> n >> m >> k; vector a(n), b(m); for (int i = 0; i < n; i++) { cin >> a.at(i); } for (int i = 0; i < m; i++) { cin >> b.at(i); } vector sa(1024), sb(1024); sa.at(0) = 1; sb.at(0) = 1; int s = 0; for (int i = 0; i < n; i++) { s ^= a.at(i); sa.at(s)++; } s = 0; for (int i = 0; i < n; i++) { s ^= b.at(i); sb.at(s)++; } vector ca(1024), cb(1024); for (int i = 0; i < 1024; i++) { ca.at(0) += sa.at(i) * (sa.at(i) - 1) / 2; ca.at(0) %= mod; cb.at(0) += sb.at(i) * (sb.at(i) - 1) / 2; cb.at(0) %= mod; } for (int i = 1; i < 1024; i++) { for (int j = 0; j < 1024; j++) { if ((i ^ j) >= j) continue; ca.at(i) += sa.at(j) * sa.at(i ^ j); ca.at(i) %= mod; cb.at(i) += sb.at(j) * sb.at(i ^ j); cb.at(i) %= mod; } } int64_t ans = 0; for (int i = 0; i < 1024; i++) { ans += ca.at(i) * cb.at(i ^ k); ans %= mod; } cout << ans << endl; }