//#define _GLIBCXX_DEBUG #include #define rep(i, n) for(int i=0; i; using vs = vector; using vi = vector; using vvi = vector; template using PQ = priority_queue; template using PQG = priority_queue, greater >; const int INF = 100010001; const ll LINF = (ll)INF*INF*10; template inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);} template inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);} template istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second;} template ostream &operator<<(ostream &os, const pair &p) { return os << p.first << ' ' << p.second;} const int mod = 1000000007; //const int mod = 998244353; struct mint { int64_t x; mint(int64_t 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(int64_t 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) {return mint(*this) /= a;} }; istream& operator>>(istream& is, mint& a) { return is >> a.x;} ostream& operator<<(ostream& os, const mint& a) { return os << a.x;} const int N = 2e5+10; const int X = 1024; //head int n, m, k; int a[N], b[N]; int suma[N+1], sumb[N+1]; int cnta[X], cntb[X]; mint jja[X], jjb[X]; mint ans; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m >> k; rep(i, n) cin >> a[i]; rep(i, m) cin >> b[i]; rep(i, n) suma[i+1] = suma[i] ^ a[i]; rep(i, m) sumb[i+1] = sumb[i] ^ b[i]; rep(i, n+1) cnta[suma[i]]++; rep(i, m+1) cntb[sumb[i]]++; rep(i, X) rep(j, X) { if(i == j) { jja[0] += mint(cnta[i])*(cnta[i]-1); } else { jja[i^j] += mint(cnta[i])*cnta[j]; } } rep(i, X) rep(j, X) { if(i == j) { jjb[0] += mint(cntb[i])*(cntb[i]-1); } else { jjb[i^j] += mint(cntb[i])*cntb[j]; } } rep(i, X) { ans += jja[i] * jjb[i^k]; } cout << ans/4 << endl; }