#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(i,m) cin >> b[i]; vector tmp1(1 << 10, 0), cnt1(1 << 10, 0); int cur = 0; for (int i = 0; i < n; i++) { tmp1[cur] += 1; cur ^= a[i]; for (int j = 0; j < (1 << 10); j++) cnt1[cur ^ j] += tmp1[j]; } vector tmp2(1 << 10, 0), cnt2(1 << 10, 0); cur = 0; for (int i = 0; i < m; i++) { tmp2[cur] += 1; cur ^= b[i]; for (int j = 0; j < (1 << 10); j++) cnt2[cur ^ j] += tmp2[j]; } mint res = 0; for (int i = 0; i < (1 << 10); i++) { int j = i ^ k; res += cnt1[i] * cnt2[j]; } cout << res.x << endl; return 0; }