func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1000 + 5;   int arr[maxn][maxn];   int main() {     int m, n, k, p, sum = 0;     bool bol = false;     cin >> n >> m >> k;     if (n % 2 != m % 2) {       cout << 0 << endl;       return 0;     }     if (m > n) {       bol = true;       swap(n, m);     }     for (int i = 0; i < k; i++) {       int x, y, z;       cin >> x >> y >> z;       if (bol) swap(x, y);       arr[x - 1][y - 1] = z;     }     cin >> p;     for (int i = 0, x, tmp; i < n; i++) {       x = 0;       tmp = 1;       for (int j = 0; j < m; j++) {         tmp *= arr[i][j];         if (arr[i][j]) x++;       }       if (x != m)         sum += m - x - 1;       else if (tmp != -1) {         cout << 0 << endl;         return 0;       }     }     sum -= m - 1;     int ans = 1;     for (int i = 0; i < sum; i++) {       ans *= 2;       ans %= p;     }     cout << ans << endl;     return 0;   }   