#include using namespace std; typedef long long int ll; typedef pair P; typedef vector VI; typedef vector VVI; const ll MOD = 1000000007; const ll INF = 1e18; #define REP(i,n) for(int i=0;i> n >> m >> x; VI a(n), b(m); REP(i,n) cin >> a[i]; REP(i,m) cin >> b[i]; bool ok=1; ll ans=power(power(power(2,n-1),m-1),x)%MOD; REP(i,x){ int tp=0; REP(j,n) tp+=(a[j]>>i)&1; REP(j,m) tp+=(b[j]>>i)&1; if(tp%2==1){ ok=0; break; } } cout << ans*ok << endl; return 0; }