#include #include using namespace std; using LL = long long; using ULL = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) const ULL M = 1000000007; ULL powm(ULL a, ULL i){ if (i == 0) return 1; ULL res = powm(a * a % M, i / 2); if (i % 2 == 1) res = res * a % M; return res; } ULL H, W; ULL X; ULL A[60][2] = {}, B[60][2] = {}; ULL ans = 1; int main(){ cin >> H >> W >> X; rep(i, H){ ULL a; cin >> a; rep(j, X) A[j][(a >> j) % 2]++; } rep(i, W){ ULL a; cin >> a; rep(j, X) B[j][(a >> j) % 2]++; } rep(i, X){ ULL tmp = 0; if ((A[i][1] + B[i][1]) % 2 == 0){ tmp = powm(2, (H - 1) * (W - 1)); } ans = ans * tmp % M; } cout << ans << endl; return 0; }