#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, n) repr(i, 0, n) #define INF 2e9 #define MOD 1000000007 //#define MOD 998244353 #define LINF (long long)4e18 #define jck 3.141592 const double EPS = 1e-10; using ll = long long; using Pi = pair; using Pl = pair; int main(){ int n,m,k; cin >> n >> m >> k; vector a(n),b(m); rep(i,n) cin >> a[i]; rep(i,m) cin >> b[i]; vector suma(n+1),sumb(m+1); rep(i,n) suma[i+1] = suma[i]^a[i]; rep(i,m) sumb[i+1] = sumb[i]^b[i]; vector cnta(1<<10),cntb(1<<10); rep(i,n+1) cnta[suma[i]]++; rep(i,m+1) cntb[sumb[i]]++; vector cnta2(1<<10),cntb2(1<<10); rep(i,1<<10)repr(j,i,1<<10){ if(i == j){ cnta2[i^j] += cnta[i]*(cnta[j]-1)/2; cntb2[i^j] += cntb[i]*(cntb[j]-1)/2; } else{ cnta2[i^j] += cnta[i]*cnta[j]; cntb2[i^j] += cntb[i]*cntb[j]; } cnta2[i^j] %= MOD; cntb2[i^j] %= MOD; } ll ans = 0; rep(i,1<<10){ ans += cnta2[i]*cntb2[i^k]%MOD; ans %= MOD; } cout << ans << endl; }