#include /*#include #include */#pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; /*namespace mp = boost::multiprecision; using Bint = mp::cpp_int; using Real = mp::number>; */#define lli long long int #define uli unsigned long long int #define INF 999999999999 #define rep(i,m,n) for(lli i = m;i < n;i++) #define rrep(i,m,n) for(lli i=m-1;i>=n;i--) #define pb(n) push_back(n) #define UE(N) N.erase(unique(N.begin(),N.end()),N.end()); #define Sort(n) sort(n.begin(), n.end()) #define Rev(n) reverse(n.begin(),n.end()) #define Out(S) cout << S << endl #define NeOut(S) cout << S #define HpOut(S) cout << setprecision(50) << S << endl #define Vec(K,L,N,S) vector K(N,S) #define DV(K,L,N,M,S) vector> K(N,vector(M,S)) #define TV(K,L,N,M,R,S) vector>> K(N,vector>(M,vector(R,S))) #define pint pair #define paf(L,R) pair #define mod 1000000007 #define MAX 10000000 #define ALL(a) a.begin(),a.end() #define chmax(a, b) a = (((a)<(b)) ? (b) : (a)) #define chmin(a, b) a = (((a)>(b)) ? (b) : (a)) int main(){ ios::sync_with_stdio(false); cin.tie(0); long long N, M, K; cin >> N >> M >> K; Vec(P,lli,N+1,0); Vec(Q,lli,M+1,0); rep(i,1,N+1)cin >> P[i]; rep(i,1,M+1)cin >> Q[i]; rep(i,1,N+1)P[i]^=P[i-1]; rep(i,1,M+1)Q[i]^=Q[i-1]; DV(A,lli,1024,2,0); DV(B,lli,1024,2,0); rep(i,0,N+1)A[P[i]][0]++; rep(i,0,M+1)B[Q[i]][0]++; rep(i,0,1024)rep(j,i,1024) { if (i == j) A[0][1] = (A[0][1] + A[i][0] * (A[i][0] - 1) / 2 % mod) % mod; else A[i^j][1] = (A[i^j][1] + A[i][0] * A[j][0] % mod) % mod; } rep(i,0,1024)rep(j,i,1024) { if (i == j) B[0][1] = (B[0][1] + B[i][0] * (B[i][0] - 1) / 2 % mod) % mod; else B[i^j][1] = (B[i^j][1] + B[i][0] * B[j][0] % mod) % mod; } long long sum = 0; rep(i,0,1024) sum = ( sum + A[i][1] * B[K^i][1] % mod ) % mod; cout << sum << endl; }