//FIRST THINK THEN CODE. #include using namespace std; typedef long long ll; #define rep(i,a,b) for(ll i=a;ib;--i) #define FOR(i,n) for(ll i=0;i #define vl vector #define ld long double #define vld vector #define vvi vector> #define vvl vector> #define vvld vector> #define pii pair #define pll pair #define vpii vector #define vpll vector #define ff first #define ss second #define pb push_back #define pf push_front #define mp make_pair #define lb lower_bound #define ub upper_bound #define bs binary_search #define d1(x) cout<<(x)< void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; } template void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...); } template void chmax( T &a, F b) { if (b > a)a = b; } template void chmin( T &a, F b) { if (b < a)a = b; } /* if you want to multiply 2 64 bit numbers mod c. i.e a*b%c. this function will help in preventing "overflow". */ ll mulmod(ll a, ll b, ll c) { ll ans = 0; ll y = a % c; while (b) { if (b & 1) { (ans += y) %= c; } y = y * 2 % c; b >>= 1; } return ans; } ll powM(ll a, ll b, ll m) { if (b < 0)return 0; if (a <= 0)return 0; a %= m; ll ans = 1LL; while (b) { if (b & 1)ans = ans * a % m; //ans = mulmod(ans, a, m); a = a * a % m; //a = mulmod(a, a, m); b >>= 1; } return ans; } ll powMbig(ll a, ll b, ll m) { if (a <= 0)return 0; a %= m; ll ans = 1LL; while (b) { if (b & 1)//ans = ans * a % m; ans = mulmod(ans, a, m); //a = a * a % m; a = mulmod(a, a, m); b >>= 1; } return ans; } ll poww(ll a, ll b) { ll ans = 1; while (b) { if (b & 1)ans = ans * a; a = a * a; b >>= 1; } return ans; } string tostring(ll x) { stringstream sss; sss << x; string ans = sss.str(); return ans; } const ll N = 1e6 + 5; ll gandu(ll c) { return (c * (c - 1) / 2) % M; } int main() { IOS; #ifndef ONLINE_JUDGE freopen("input1.txt", "r", stdin); freopen("output1.txt", "w", stdout); #endif ll n, m, k; cin >> n >> m >> k; vl a(n); ll s1 = 0; vl f1(2100); f1[0] = 1; FOR(i, n) { ll x; cin >> x; s1 ^= x; f1[s1]++; } ll s2 = 0; vl f2(2100); f2[s2] = 1; FOR(i, m) { ll x; cin >> x; s2 ^= x; f2[s2]++; } vl f3(2100), f4(2100); for (ll i = 0; i < 1025; i++) { for (ll j = i; j < 1025; j++) { if (i == j)(f3[0] += gandu(f1[i])) %= M; else (f3[i ^ j] += f1[i] * f1[j] % M) %= M; } } //FOR(i, 4)d2(i, f3[i]); for (ll i = 0; i < 1025; i++) { for (ll j = i; j < 1025; j++) { if (i == j)(f4[0] += gandu(f2[i])) %= M; else (f4[i ^ j] += f2[i] * f2[j] % M) %= M; } } ll ans = 0; for (ll i = 0; i < 1025; i++) { ans = (ans + f3[i] * f4[i ^ k] % M) % M; } cout << ans << endl; return 0; }