#include using namespace std; #if __has_include() #include using namespace atcoder; #endif using ll = long long; using ld = long double; #define all(s) (s).begin(),(s).end() #define vcin(n) for(ll i=0;i>n[i] #define rep2(i, m, n) for (int i = (m); i < (n); ++i) #define rep(i, n) rep2(i, 0, n) #define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i) #define drep(i, n) drep2(i, n, 0) #define rever(vec) reverse(vec.begin(), vec.end()) #define sor(vec) sort(vec.begin(), vec.end()) #define fi first #define se second //#define P pair //const ll mod = 998244353; const ll mod = 1000000007; const ll inf = 2000000000000000000ll; static const long double pi = 3.141592653589793; void YesNo(bool a){if(a){cout<<"Yes"< void chmax(T& t,const U& u){if(t void chmin(T& t,const U& u){if(t>u) t=u;} ll modPow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; } template void xorFFT(vector &a, bool inv=false) { int n((a.size())); for (int step(1); step < n; step *= 2) for (int i(0); i < n; i += 2 * step) for (int j(i); j < i + step; ++j) { T &u = a[j], &v = a[j+step]; tie(u, v) = //inv ? make_pair(v-u, u) : make_pair(v, u+v); // AND //inv ? make_pair(v, u-v) : make_pair(u+v, u); // OR make_pair(u+v, u-v); // XOR } // XOR ONLY if (inv) for (T& x : a) x /= (a.size()); } template vector xorConv(vector a, vector b) { xorFFT(a); xorFFT(b); for (int i(0); i < int(b.size()); ++i) a[i] *= b[i]; xorFFT(a, true); return a; } int main() { /* mod は 1e9+7 */ ios::sync_with_stdio(false); std::cin.tie(nullptr); cout<< fixed << setprecision(10); vector a(1024); vector b(1024); ll n,m,k; cin>>n>>m>>k; vector x(n+1); vector y(m+1); for(int i=1;i<=n;i++){ cin>>x[i]; } for(int i=1;i<=m;i++){ cin>>y[i]; } for(int i=1;i<=n;i++){ x[i]^=x[i-1]; } for(int i=1;i<=m;i++){ y[i]^=y[i-1]; } for(int i=0;i<=n;i++){ a[x[i]]++; } for(int i=0;i<=m;i++){ b[y[i]]++; } auto p=xorConv(a,a); auto q=xorConv(b,b); p[0]-=n+1; q[0]-=m+1; for(int i=0;i<1024;i++){ p[i]/=2; p[i]%=mod; } for(int i=0;i<1024;i++){ q[i]/=2; q[i]%=mod; } auto ans=xorConv(p,q); cout<