#include #include #include #include #include #include #include #include #include #include #include using namespace std; #define MOD 1000000007 #define MOD2 998244353 #define INF (1<<29) #define LINF (1LL<<60) #define EPS (1e-10) #define PI 3.1415926535897932384626433832795028 typedef long long Int; typedef pair P; typedef long double Real; typedef complex CP; Int a, b; Int accum_a, accum_b; Int cnt_a[1 << 10], cnt_b[1 << 10]; Int pcnt_a[1<<10], pcnt_b[1<<10]; Int n, m, k; int main(){ cin >> n >> m >> k; cnt_a[0]++; for(Int i = 0;i < n;i++){ cin >> a; accum_a ^= a; cnt_a[accum_a]++; } cnt_b[0]++; for(Int i = 0;i < m;i++){ cin >> b; accum_b ^= b; cnt_b[accum_b]++; } for(Int i = 0;i < (1 << 10);i++){ (pcnt_a[0] += cnt_a[i] * (cnt_a[i]-1) / 2) %= MOD; (pcnt_b[0] += cnt_b[i] * (cnt_b[i]-1) / 2) %= MOD; for(Int j = i+1;j < (1 << 10);j++){ (pcnt_a[i^j] += cnt_a[i] * cnt_a[j] % MOD) %= MOD; (pcnt_b[i^j] += cnt_b[i] * cnt_b[j] % MOD) %= MOD; } } Int ans = 0; for(Int i = 0;i < (1<<10);i++){ (ans += pcnt_a[i] * pcnt_b[i^k] % MOD) %= MOD; } cout << ans << endl; return 0; }