#include <bits/stdc++.h>   using namespace std;   vector<vector<pair<int, char> > > adj(201);   int dp[101][101][26][2];   bool solve(int i, int j, char round, bool turn) {     if (dp[i][j][(int)(round -  a )][turn] != -1)       return dp[i][j][(int)(round -  a )][turn];     int ret = 0;     if (!turn) {       for (int k = 0; k < adj[i].size(); k++) {         if (adj[i][k].second >= round)           if (!solve(adj[i][k].first, j, adj[i][k].second, !turn)) ret = 1;       }     } else {       for (int k = 0; k < adj[j].size(); k++) {         if (adj[j][k].second >= round)           if (!solve(i, adj[j][k].first, adj[j][k].second, !turn)) ret = 1;       }     }     return dp[i][j][(int)(round -  a )][turn] = ret;   }   int main() {     memset(dp, -1, sizeof dp);     int n, m;     cin >> n >> m;     for (int i = 0; i < m; i++) {       int x, y;       char z;       cin >> x >> y >> z;       adj[x].push_back({y, z});     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         int h = solve(i, j,  a , 0);         if (h == 1)           cout <<  A ;         else           cout <<  B ;       }       cout << endl;     }     return 0;   }   