#include using namespace std; #define X first #define Y second #define mp make_pair #define pb push_back #define rep(i,a,n) for(int i=(a);i<=(n);++i) #define dep(i,a,n) for(int i=(a);i>=(n);--i) #define eps 1e-8 #define pi 3.1415926535897 #define sqr(x) ((x)*(x)) #define SZ(x) ((int)(x).size()) #define CPY(a,b) memcpy(a,b,sizeof(a)) #define CLR(a) memset(a,0,sizeof(a)) #define POSIN(x,y) (1<=(x)&&(x)<=m&&1<=(y)&&(y)<=n) #define ALL(x) (x).begin(),(x).end() #define COUT(S,x) cout< bool MAX(T &m, const T q) { if (m < q) {m = q; return true;} else return false; } template bool MIN(T &m, const T q) { if (m > q) {m = q; return true;} else return false; } template pair operator+(const pair &l, const pair &r) { return make_pair(l.first + r.first, l.second + r.second); } template pair operator-(const pair &l, const pair &r) { return make_pair(l.first - r.first, l.second - r.second); } template ostream &operator<<(ostream &os, const vector &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; } template ostream &operator<<(ostream &os, const deque &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; } template ostream &operator<<(ostream &os, const set &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template ostream &operator<<(ostream &os, const unordered_set &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template ostream &operator<<(ostream &os, const multiset &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template ostream &operator<<(ostream &os, const unordered_multiset &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template ostream &operator<<(ostream &os, const pair &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; } template ostream &operator<<(ostream &os, const map &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; } template ostream &operator<<(ostream &os, const unordered_map &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; } typedef long long ll; typedef double lf; typedef pair pii; typedef pair pll; typedef pair pff; typedef complex CD; typedef vector VI; typedef vector VL; const int inf=0x3f3f3f3f; const int mo=1000000007; inline void gn(long long&x){ int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0'); while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg; } inline void gn(int&x){long long t;gn(t);x=t;} inline void gn(unsigned long long&x){long long t;gn(t);x=t;} inline void gn(double&x){double t;scanf("%lf",&t);x=t;} inline void gn(long double&x){double t;scanf("%lf",&t);x=t;} templateinline void gn(T1&r,T2&s){gn(r),gn(s);} templateinline void gn(T1&r,T2&s,T3&t){gn(r),gn(s),gn(t);} templateinline void gn(T1&r,T2&s,T3&t,T4&u){gn(r),gn(s),gn(t),gn(u);} inline void gs(char *s){scanf("%s",s);} inline void gc(char &c){while((c=getchar())>126 || c<33);} inline void pc(char c){putchar(c);} const int DX[]={1,0,-1,0},DY[]={0,1,0,-1}; ll powmod(ll a,ll b) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;} ll powmod(ll a,ll b,ll mo) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;} ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;} //******************************************* const int N=1111111,M=111111; int l,m,n,t,C; int a[N],b[N],aa[N],bb[N]; int main(){ #ifdef LOCAL freopen("D.in","r",stdin);//freopen("D.out","w",stdout); #endif scanf("%d%d%d",&n,&m,&t); rep(i,1,n)scanf("%d",&a[i]); rep(i,1,m)scanf("%d",&b[i]); rep(i,2,n)a[i]^=a[i-1]; rep(i,2,m)b[i]^=b[i-1]; rep(i,0,n)aa[a[i]]++; rep(i,0,m)bb[b[i]]++; ll ans=0; rep(p,0,1023){ ll res=1; ll cnt=0; rep(i,0,n){cnt+=aa[a[i]^p];if(p==0)--cnt;} res*=cnt/2; cnt=0; rep(i,0,m){cnt+=bb[b[i]^(p^t)];if((p^t)==0)--cnt;} res*=cnt/2; ans+=res; ans%=mo; } printf("%d\n",int(ans)); return 0; }