#include #include #include #include #include #include #include #include #include #include #include #include #include constexpr long long int MOD = 1000000007; long long int power(long long int base, long long int exp) { long long int result{ 1 }; while (exp > 0) { if (exp & 1) { result = (result * base) % MOD; --exp; } else { base = (base * base) % MOD; exp >>= 1; } } return result; } int main() { int n, m, x; std::cin >> n >> m >> x; std::vector row(n), column(m); for (auto& r : row) std::cin >> r; for (auto& c : column) std::cin >> c; const auto row_xor = std::accumulate(row.begin(), row.end(), 0LL, [](const long long int acc, const long long int r) {return acc ^ r; }); const auto column_xor = std::accumulate(column.begin(), column.end(), 0LL, [](const long long int acc, const long long int l) {return acc ^ l; }); if (row_xor != column_xor) { std::cout << 0 << '\n'; return 0; } std::cout << power((1LL << x) % MOD, (n - 1) * (m - 1)) << '\n'; }