#include using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef unsigned long long ll; typedef long double ld; typedef pair P; constexpr int mod = 1e9+7; struct mint { ll x; // typedef long long ll; mint(ll x=0):x((x%mod+mod)%mod){} mint operator-() const { return mint(-x);} mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;} mint operator+(const mint a) const { return mint(*this) += a;} mint operator-(const mint a) const { return mint(*this) -= a;} mint operator*(const mint a) const { return mint(*this) *= a;} mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod-2);} mint& operator/=(const mint a) { return *this *= a.inv();} mint operator/(const mint a) const { return mint(*this) /= a;} }; int main() { int n, m, k; cin >> n >> m >> k; vector a(n), b(m); rep(i,n) cin >> a[i]; rep(j,m) cin >> b[j]; vector a_cum(n + 1, 0), b_cum(m + 1, 0); for (int i = 0; i < n; i++) a_cum[i + 1] = a_cum[i] ^ a[i]; for (int i = 0; i < m; i++) b_cum[i + 1] = b_cum[i] ^ b[i]; vector a_cnt(1 << 10, 0), b_cnt(1 << 10, 0); for (int i = 0; i <= n; i++) a_cnt[a_cum[i]] += 1; for (int j = 0; j <= m; j++) b_cnt[b_cum[j]] += 1; vector dp1(1 << 10, 0), dp2(1 << 10, 0); for (int i = 0; i < (1 << 10); i++) { for (int j = 0; j < (1 << 10); j++) { dp1[i ^ j] += a_cnt[i] * (a_cnt[j] - (i == j ? 1 : 0)); dp2[i ^ j] += b_cnt[i] * (b_cnt[j] - (i == j ? 1 : 0)); } } mint res = 0; for (int i = 0; i < (1 << 10); i++) dp1[i] /= 2, dp2[i] /= 2; for (int i = 0; i < (1 << 10); i++) res += dp1[i] * dp2[i ^ k]; cout << res.x << endl; return 0; }