#include using namespace std; #define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i) #define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i) #define all(n) begin(n), end(n) using ll = long long; using P = pair; using vi = vector; using vl = vector; using vs = vector; using vc = vector; using vb = vector; using vd = vector; vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1}; const int mod = 1000000007; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint& operator+=(const mint a) { if((x += a.x) >= mod) x -= mod; return *this; } mint& operator-=(const mint a) { if((x += mod - a.x) >= mod) x -= mod; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(ll t) const { if(!t) return 1; mint a = pow(t >> 1); a *= a; if(t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint& operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } }; istream& operator>>(istream& is, const mint& a) { return is >> a.x; } ostream& operator<<(ostream& os, const mint& a) { return os << a.x; } mint fact(int n) { if(n == 1 || n == 0) return 1; mint res = n; return res * fact(n - 1); } int main() { ll n, m, k; cin >> n >> m >> k; vl a(n), b(m); rep(i, n) cin >> a[i]; rep(i, m) cin >> b[i]; vl ax(1024, 0), bx(1024, 0); ax[0]++; bx[0]++; ll t = 0; rep(i, n) { t ^= a[i]; ax[t]++; } t = 0; rep(i, m) { t ^= b[i]; bx[t]++; } vector ac(1024, 0), bc(1024, 0); rep(i, 1024) rep2(j, i, 1024) { if(i == j) ac[0] += ax[i] * (ax[i] - 1) / 2; else ac[i ^ j] += ax[i] * ax[j]; } rep(i, 1024) rep2(j, i, 1024) { if(i == j) bc[0] += bx[i] * (bx[i] - 1) / 2; else bc[i ^ j] += bx[i] * bx[j]; } mint ans = 0; rep(i, 1024) ans += ac[i] * bc[i ^ k]; cout << ans << endl; }