#include #define r(i,m,n) for(int i=m;i>N>>M>>K;vectorP(N+1),Q(M+1),A(n),B(n),C(n),D(n);r(i,1,N+1)cin>>P[i];r(i,1,M+1)cin>>Q[i];r(i,1,N+1)P[i]^=P[i-1];r(i,1,M+1)Q[i]^=Q[i-1];r(i,0,N+1)A[P[i]]++;r(i,0,M+1)B[Q[i]]++;r(i,0,n)r(j,i,n){if(i==j){C[0]=(C[0]+A[i]*(A[i]-1)/2)%m;D[0]=(D[0]+B[i]*(B[i]-1)/2)%m;}else{C[i^j]=(C[i^j]+A[i]*A[j])%m;D[i^j]=(D[i^j]+B[i]*B[j]%m);}}r(i,0,n)s=(s+C[i]*D[K^i]%m)%m;cout<