#pragma GCC optimize("O3") #include #define ll long long #define rep(i,n) for(ll i=0;i<(n);i++) #define pll pair #define pq priority_queue #define pb push_back #define eb emplace_back #define fi first #define se second #define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define lb(c,x) distance(c.begin(),lower_bound(all(c),x)) #define ub(c,x) distance(c.begin(),upper_bound(all(c),x)) using namespace std; template inline bool chmax(T& a,T b){if(a inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;} const ll INF=1e18; const ll mod=1e9+7; const double eps=0.000000001; int main(){ ll n,m,k; cin >> n >> m >> k; vector a(n),b(m); vector p(1024),q(1024),x(1024),y(1024); rep(i,n){ cin >> a[i]; } rep(i,m){ cin >> b[i]; } ll s=0; p[s]=1; rep(i,n){ s=s^a[i]; rep(j,1024){ ll val=s^j; x[val]+=p[j]; x[val]%=mod; } p[s]++; } ll t=0; q[t]=1; rep(i,m){ t=t^b[i]; rep(j,1024){ ll val=t^j; y[val]+=q[j]; y[val]%=mod; } q[t]++; } ll ans=0; rep(i,1024){ rep(j,1024){ ll v=i^j; if(k==v){ ans+=(x[i]*y[j])%mod; ans%=mod; } } } cout << ans << endl; return 0; }