func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   const int mod = 1e9 + 7;   const int N = 100 + 10;   inline int add(int x, int y) {     x += y;     if (x >= mod) x -= mod;     return x;   }   inline int mul(int x, int y) {     x = (1LL * x * y) % mod;     return x;   }   vector<pair<int, int> > G[N];   int dp[N][N][30][2];   int f(int i, int j, int last, int turn) {     int &ret = dp[i][j][last][turn];     if (~ret) return ret;     ret = 0;     if (turn == 1) {       for (auto it : G[i]) {         int nxt = it.first;         int ed = it.second;         if (ed >= last) {           int x = f(nxt, j, ed, 0);           if (x == 0) return ret = 1;         }       }     } else {       for (auto it : G[j]) {         int nxt = it.first;         int ed = it.second;         if (ed >= last) {           int x = f(i, nxt, ed, 1);           if (x == 0) return ret = 1;         }       }     }     return ret;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     memset(dp, -1, sizeof(dp));     int n, m;     cin >> n >> m;     for (int i = 0; i <= m - 1; ++i) {       int u, v;       cin >> u >> v;       char c;       cin >> c;       int x = c -  a ;       G[u].push_back({v, x});     }     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= n; ++j) {         int curr = f(i, j, 0, 1);         if (curr == 0)           cout <<  B ;         else           cout <<  A ;       }       cout <<   n ;     }     return 0;   }   