#include using namespace std; using ll = long long; using ld = long double; using pcc = pair; using pii = pair; using pll = pair; using pdd = pair; using tuplis = array; template using prique = priority_queue,greater>; #define rep(i,n) for(ll i = 0; i < n; i++) #define rrep(i,n) for(ll i = n-1; i >= 0; i--) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define Sort(a) sort(all(a)) #define Rev(a) reverse(all(a)) #define Uniq(a) sort(all(a));a.erase(unique(all(a)),a.end()) const ll LINF = 1001001001001001001; const int INF = 1001001001; const int MOD = 1000000007; const int MODD = 998244353; const ld PI = 3.1415926535897932; const ll dx[] = {0, 1, 0, -1, 1, -1, 1, -1}; const ll dy[] = {1, 0, -1, 0, 1, 1, -1, -1}; inline ll popcnt(ll a){ return __builtin_popcountll(a); } inline ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; } inline ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; } ll gcd(ll a,ll b){ if(a%b == 0){return b; } else{ return gcd(b,a%b); } } ll lcm(ll a,ll b){ return a/gcd(a,b)*b; } template bool chmin(T& a, const T& b){ if(a > b){ a = b; return 1; } return 0; } template bool chmax(T& a, const T& b){ if(a < b){ a = b; return 1; } return 0; } template bool chmin(T& a, const U& b){ if(a > T(b)){ a = b; return 1; } return 0; } template bool chmax(T& a, const U& b){ if(a < T(b)){ a = b; return 1; } return 0; } int main() { ll N,M,K; cin >> N >> M >> K; vectora(N),b(M); vectorA(1030),B(1030); A[0]++; B[0]++; ll ax = 0,bx = 0; rep(i,N) { cin >> a[i]; ax ^= a[i]; A[ax]++; } rep(i,M) { cin >> b[i]; bx ^= b[i]; B[bx]++; } vectorA2(1030),B2(1030); rep(i,1 << 10) { for(ll j = i; j < (1 << 10); j++) { if(i == j) { A2[0] += (ll)(A[i]*(A[i]-1)/2)%MOD; A2[0] %= MOD; B2[0] += (ll)(B[i]*(B[i]-1)/2)%MOD; B2[0] %= MOD; } else { A2[i^j] += (ll)(A[i]*A[j])%MOD; A2[i^j] %= MOD; B2[i^j] += (ll)(B[i]*B[j])%MOD; B2[i^j] %= MOD; } } } ll ans = 0; rep(i,1 << 10) { ans += A2[i]*B2[i^K]%MOD; ans %= MOD; } cout << ans << endl; }