ll n,m,k,a[1d6],b[1d6],M=1024,X;ll s(ll*e,Mint*A,ll l){Mint C[M];C[X=0]=1;rep(i,l)C[X^=e[i]]+=1;rep(i,M){rep(j,i)A[i^j]+=C[i]*C[j];A[0]+=C[i]*(C[i]-1)/2;}}{rd(n,m,k,a(n),b(m));Mint A[M],B[M],R;s(a,A,n);s(b,B,m);rep(i,M)R+=A[i]*B[k^i];wt(R);}