func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5e4 + 2;   int head[N], grp_edge[N][30], max1[N][30], grp[N], level[N], okfine = 0, sum[N],                                                                dem = 0;   char edge[N];   bool cac = true;   vector<pair<int, char> > adj[N];   vector<int> adj_grp[N];   stack<pair<int, char> > lis;   void dfs(int x) {     int i = 0, j;     if (adj[x].size() == 0) {       if (!okfine) {         okfine = level[x];       }       if (okfine != level[x]) {         cac = false;       }       while (lis.size()) {         i = lis.top().first;         if (lis.top().second !=  ? ) {           grp_edge[x][(int)(lis.top().second -  a  + 1)]++;         }         grp[i] = x;         lis.pop();       }       if (i) {         adj_grp[head[i]].push_back(x);         head[x] = head[i];       }     }     if (adj[x].size() == 1) {       level[adj[x][0].first] = level[x] + 1;       lis.push({adj[x][0].first, edge[adj[x][0].first]});       dfs(adj[x][0].first);     }     if (adj[x].size() == 2) {       while (lis.size()) {         i = lis.top().first;         if (lis.top().second !=  ? ) {           grp_edge[x][(int)(lis.top().second -  a  + 1)]++;         }         grp[i] = x;         lis.pop();       }       if (i) {         adj_grp[head[i]].push_back(x);         head[x] = head[i];       }       level[adj[x][0].first] = level[x] + 1;       lis.push({adj[x][0].first, edge[adj[x][0].first]});       dfs(adj[x][0].first);       level[adj[x][1].first] = level[x] + 1;       lis.push({adj[x][1].first, edge[adj[x][1].first]});       dfs(adj[x][1].first);     }   }   void dfs1(int x) {     int i, j;     for (i = 0; i < adj_grp[x].size(); i++) {       dfs1(adj_grp[x][i]);       for (j = 1; j <= 26; j++) {         max1[x][j] =             max(max1[x][j], max1[adj_grp[x][i]][j] + grp_edge[adj_grp[x][i]][j]);       }     }     for (j = 1; j <= 26; j++) {       sum[x] += max1[x][j];     }     if (sum[x] > okfine - level[x]) {       dem++;     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, i, j, k, l, q, ans, ans1;     char x, x1;     cin >> n >> q;     for (i = 2; i <= n; i++) {       cin >> head[i] >> edge[i];       adj[head[i]].push_back({i, edge[i]});     }     dfs(1);     dfs1(1);     head[1] = 0;     for (i = 1; i <= q; i++) {       if (!cac) {         cout <<  Fou n ;         continue;       }       cin >> j >> x;       x1 = edge[j];       if (edge[j] !=  ? ) {         grp_edge[grp[j]][(int)(edge[j] -  a  + 1)]--;       }       edge[j] = x;       if (edge[j] !=  ? ) {         grp_edge[grp[j]][(int)(edge[j] -  a  + 1)]++;       }       k = grp[j];       while (k != 1) {         if (adj_grp[head[k]].size() == 2) {           if (sum[head[k]] > okfine - level[head[k]]) {             if (x1 !=  ? ) {               sum[head[k]] -= max1[head[k]][(int)(x1 -  a  + 1)];               max1[head[k]][(int)(x1 -  a  + 1)] =                   max(max1[adj_grp[head[k]][0]][(int)(x1 -  a  + 1)] +                           grp_edge[adj_grp[head[k]][0]][(int)(x1 -  a  + 1)],                       max1[adj_grp[head[k]][1]][(int)(x1 -  a  + 1)] +                           grp_edge[adj_grp[head[k]][1]][(int)(x1 -  a  + 1)]);               sum[head[k]] += max1[head[k]][(int)(x1 -  a  + 1)];             }             if (x !=  ? ) {               sum[head[k]] -= max1[head[k]][(int)(x -  a  + 1)];               max1[head[k]][(int)(x -  a  + 1)] =                   max(max1[adj_grp[head[k]][0]][(int)(x -  a  + 1)] +                           grp_edge[adj_grp[head[k]][0]][(int)(x -  a  + 1)],                       max1[adj_grp[head[k]][1]][(int)(x -  a  + 1)] +                           grp_edge[adj_grp[head[k]][1]][(int)(x -  a  + 1)]);               sum[head[k]] += max1[head[k]][(int)(x -  a  + 1)];             }             if (sum[head[k]] <= okfine - level[head[k]]) {               dem--;             }           } else {             if (x1 !=  ? ) {               sum[head[k]] -= max1[head[k]][(int)(x1 -  a  + 1)];               max1[head[k]][(int)(x1 -  a  + 1)] =                   max(max1[adj_grp[head[k]][0]][(int)(x1 -  a  + 1)] +                           grp_edge[adj_grp[head[k]][0]][(int)(x1 -  a  + 1)],                       max1[adj_grp[head[k]][1]][(int)(x1 -  a  + 1)] +                           grp_edge[adj_grp[head[k]][1]][(int)(x1 -  a  + 1)]);               sum[head[k]] += max1[head[k]][(int)(x1 -  a  + 1)];             }             if (x !=  ? ) {               sum[head[k]] -= max1[head[k]][(int)(x -  a  + 1)];               max1[head[k]][(int)(x -  a  + 1)] =                   max(max1[adj_grp[head[k]][0]][(int)(x -  a  + 1)] +                           grp_edge[adj_grp[head[k]][0]][(int)(x -  a  + 1)],                       max1[adj_grp[head[k]][1]][(int)(x -  a  + 1)] +                           grp_edge[adj_grp[head[k]][1]][(int)(x -  a  + 1)]);               sum[head[k]] += max1[head[k]][(int)(x -  a  + 1)];             }             if (sum[head[k]] > okfine - level[head[k]]) {               dem++;             }           }         } else {           if (sum[head[k]] > okfine - level[head[k]]) {             if (x1 !=  ? ) {               sum[head[k]] -= max1[head[k]][(int)(x1 -  a  + 1)];               max1[head[k]][(int)(x1 -  a  + 1)] =                   max1[adj_grp[head[k]][0]][(int)(x1 -  a  + 1)] +                   grp_edge[adj_grp[head[k]][0]][(int)(x1 -  a  + 1)];               sum[head[k]] += max1[head[k]][(int)(x1 -  a  + 1)];             }             if (x !=  ? ) {               sum[head[k]] -= max1[head[k]][(int)(x -  a  + 1)];               max1[head[k]][(int)(x -  a  + 1)] =                   max1[adj_grp[head[k]][0]][(int)(x -  a  + 1)] +                   grp_edge[adj_grp[head[k]][0]][(int)(x -  a  + 1)];               sum[head[k]] += max1[head[k]][(int)(x -  a  + 1)];             }             if (sum[head[k]] <= okfine - level[head[k]]) {               dem--;             }           } else {             if (x1 !=  ? ) {               sum[head[k]] -= max1[head[k]][(int)(x1 -  a  + 1)];               max1[head[k]][(int)(x1 -  a  + 1)] =                   max1[adj_grp[head[k]][0]][(int)(x1 -  a  + 1)] +                   grp_edge[adj_grp[head[k]][0]][(int)(x1 -  a  + 1)];               sum[head[k]] += max1[head[k]][(int)(x1 -  a  + 1)];             }             if (x !=  ? ) {               sum[head[k]] -= max1[head[k]][(int)(x -  a  + 1)];               max1[head[k]][(int)(x -  a  + 1)] =                   max1[adj_grp[head[k]][0]][(int)(x -  a  + 1)] +                   grp_edge[adj_grp[head[k]][0]][(int)(x -  a  + 1)];               sum[head[k]] += max1[head[k]][(int)(x -  a  + 1)];             }             if (sum[head[k]] > okfine - level[head[k]]) {               dem++;             }           }         }         k = head[k];       }       if (dem) {         cout <<  Fou n ;       } else {         ans = 0;         ans1 = 0;         for (j = 1; j <= 26; j++) {           ans += max1[1][j] * j;           ans1 += max1[1][j];         }         cout <<  Shi   << ans + (okfine - ans1) * 27 * 13 << endl;       }     }   }   