#include using namespace std; typedef long long int ll; typedef pair P; typedef vector VI; typedef vector VVI; const ll MOD = 1000000007; const ll INF = 1e18; #define REP(i, n) for(int i = 0; i < n; i++) #define ALL(v) v.begin(), v.end() int main() { int n, m, k; cin >> n >> m >> k; VI a(n), b(m); REP(i,n) cin >> a[i]; REP(i,m) cin >> b[i]; VI sa(n+1,0), sb(m+1,0); REP(i,n) sa[i+1]=sa[i]^a[i]; REP(i,m) sb[i+1]=sb[i]^b[i]; VI pa(1024,0), pb(1024,0); REP(i,n+1) pa[sa[i]]++; REP(i,m+1) pb[sb[i]]++; VI qa(1024,0), qb(1024,0); for(int i=0;i<1024;i++){ for(int j=i;j<1024;j++){ int x=i^j; if(x==0){ qa[x]+=pa[i]*(pa[i]-1)/2; qb[x]+=pb[i]*(pb[i]-1)/2; } else{ qa[x]+=pa[i]*pa[j]; qb[x]+=pb[i]*pb[j]; } } } ll ans=0; for(int i=0;i<1024;i++){ int x=k^i; ans+=qa[i]*qb[x]; } cout << ans << endl; return 0; }