#include const long long mod = 1e9+7; long long countA[2048], countB[2048]; long long map[2048]; int a[200005], b[200005]; void preWork(int seq[],int n,long long count[]){ for(int i = 0; i < 1024; i++) map[i] = count[i] = 0; map[0] = 1; int prefix = 0; for(int i = 1; i <= n; i++){ int u = prefix^seq[i]; prefix = u; for(int j = 0; j < 1024; j++){ count[j] += map[u^j]; if(count[j]>=mod) count[j] -= mod; } map[u]++; } } int main(){ int n,m,k; scanf("%d%d%d",&n,&m,&k); for(int i = 1; i <= n; i++) scanf("%d",&a[i]); preWork(a,n,countA); //for(int i = 0; i < 1024; i++) if(countA[i]!=0) printf("countA[%d] = %lld\n",i,countA[i]); for(int i = 1; i <= m; i++) scanf("%d",&b[i]); preWork(b,m,countB); //for(int i = 0; i < 1024; i++) if(countB[i]!=0) printf("countB[%d] = %lld\n",i,countB[i]); long long ans = 0; for(int i = 0; i < 1024; i++){ ans += countA[i]*countB[k^i]; if(ans>=mod) ans -= mod; } printf("%lld\n",ans); return 0; }