#include using namespace std; typedef long long ll; const ll mod = 1e9+7; int main(){ int n, m, k; cin >> n >> m >> k; int a[n], b[m]; for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i < m; i++) cin >> b[i]; int acca[1<<10] = {}, accb[1<<10] = {}, ax[1<<10] = {}, bx[1<<10] = {}; int tmp = 0; acca[0] = accb[0] = 1; for(int i = 0; i < n; i++){ tmp ^= a[i]; for(int j = 0; j < 1<<10; j++){ ax[j^tmp] += acca[j]; ax[j^tmp] %= mod; } acca[tmp]++; } tmp = 0; for(int i = 0; i < m; i++){ tmp ^= b[i]; for(int j = 0; j < 1<<10; j++){ bx[j^tmp] += accb[j]; bx[j^tmp] %= mod; } accb[tmp]++; } ll ans = 0; for(int i = 0; i < 1<<10; i++){ ans += (ll)(ax[i]) * bx[k^i] % mod; ans %= mod; } cout << ans << endl; return 0; }