func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 5;   const long long p = 1e9 + 7;   int par[MAXN][2], size[MAXN][2], dist[MAXN][2], val[MAXN][2];   int groups, n, k;   pair<int, int> find(int e, int x) {     if (par[x][e] == x) {       return pair<int, int>(x, 0);     }     pair<int, int> t = find(e, par[x][e]);     t.second += dist[x][e];     t.second %= 2;     dist[x][e] = t.second;     par[x][e] = t.first;     return t;   }   bool assign(int e, int x, int v) {     find(e, x);     if (val[par[x][e]][e] == -1) {       val[par[x][e]][e] = (dist[x][e] + v) % 2;       --groups;       return true;     }     if (val[par[x][e]][e] != (dist[x][e] + v) % 2) return false;     return true;   }   bool addedge(int e, int x, int y, int v) {     find(e, x);     find(e, y);     if (par[x][e] == par[y][e]) return ((dist[x][e] + dist[y][e] + v) % 2 == 0);     v = (dist[x][e] + dist[y][e] + v) % 2;     x = par[x][e];     y = par[y][e];     if (size[x][e] > size[y][e]) swap(x, y);     par[x][e] = y;     dist[x][e] = v;     size[y][e] += size[x][e];     if (val[y][e] != -1 && val[x][e] != -1) {       if ((val[x][e] + val[y][e] + v) % 2 != 0) return false;       return true;     }     if (val[x][e] != -1) {       val[y][e] = (val[x][e] + v) % 2;       --groups;       return true;     }     --groups;     return true;   }   int main() {     cin >> n >> k;     groups = 2 * n - 1;     for (int i = 0; i < MAXN; ++i) {       par[i][0] = par[i][1] = i;       size[i][0] = size[i][1] = 1;       dist[i][0] = dist[i][1] = 0;       val[i][0] = val[i][1] = -1;     }     for (int i = 0; i < k; ++i) {       int x, y, v;       char j;       cin >> x >> y >> j;       v = (j ==  o );       x--;       y--;       if (abs(x - y) <= 1) {         if (!assign((x + y) % 2, min(x, y), v)) {           cout <<  0  << endl;           return 0;         }       } else {         if (x > y) swap(x, y);         if (!addedge((x + y) % 2, (y - x - (x + y) % 2) / 2 - 1,                      (y - x - (x + y) % 2) / 2 + x, v)) {           cout <<  0  << endl;           return 0;         }       }     }     for (int i = 0; i < n / 2; ++i) {       if (!addedge(0, i, n - 1 - i, 0)) {         cout <<  0  << endl;         return 0;       }     }     for (int i = 0; i < (n - 1) / 2; ++i) {       if (!addedge(1, i, n - 2 - i, 0)) {         cout <<  0  << endl;         return 0;       }     }     long long prod = 1;     for (int i = 0; i < groups; ++i) {       prod *= 2;       prod %= p;     }     cout << prod << endl;   }   