#include <bits/stdc++.h>
using namespace std;
// * No One Dies a Virgin, Life Fucks Us All
typedef long long ll;
#define nl '\n'
#define ff first
#define ss second
#define pb push_back
#define sik(x) {cout << x << nl; return;}
constexpr ll maxn = 2e5+10, mod = 1e9 + 7, inf = 1e17, SQ = 450, LG = 20;
typedef pair<int, int> pii;
constexpr inline ll pw(ll a, ll b, const ll mod = mod) {
  ll res = 1;
  for (; b ; b /= 2, a = a * a % mod) if (b & 1) res = res * a % mod;
  return res;
}
int n, m, k;
map<int, int> R, C;
char c;
inline bool chk(int f) {
  for (auto&& [_, v] : C) {
    if (v != f) return 0;
  }
  return 1;
}
int32_t main() {
  cin.tie(0)->sync_with_stdio(0); 
  cin >> n >> m >> k;
  bool row = 1, col = 1;
  for (int x, y ; k -- ; ) {
    cin >> c >> x >> y;
    int f = (c == '+') ^ (x & 1) ^ (y & 1); 
    if (R.count(x)) row &= (R[x] == f);
    else R[x] = f;
    if (C.count(y)) col &= (C[y] == f);
    else C[y] = f;
  }
  ll ans = 0;
  if (row) ans += pw(2, n - R.size());
  if (col) ans += pw(2, m - C.size());
  if (row || col) {
    if (chk(0)) ans += mod - 1;
    if (chk(1)) ans += mod - 1;
  }
  while (ans >= mod) ans -= mod;
  cout << ans << nl;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |