func_code_string: #include <bits/stdc++.h>   using namespace std;   const int max_n = 300011, log_n = 32, max_m = 111, mod = 1000000007,             inf = 1011111111;   const long double eps = 1e-7;   struct bor {     stack<pair<int, int> > st;     int t[max_n][27], res[max_n], sz[max_n], n;     bor() {       for (int i = 0; i < max_n; ++i) {         for (int q = 0; q < 27; ++q) {           t[i][q] = -1;         }       }     }     void add(int x, int y, char c) { t[x][c -  a ] = y; }     int get_sz(int v) {       int ans = 1;       for (int i = 0; i < 26; ++i) {         if (t[v][i] != -1) {           ans += get_sz(t[v][i]);         }       }       return sz[v] = ans;     }     int mrg(int v, int v1) {       int ans = 1;       for (int i = 0; i < 27; ++i) {         if (t[v][i] != -1 && t[v1][i] != -1) {           ans += mrg(t[v][i], t[v1][i]);         } else if (t[v][i] != -1) {           t[v1][i] = t[v][i];           st.push(make_pair(v1, i));         }       }       return ans;     }     void get(int v, int p) {       int mx = 0, mxx = -1;       for (int i = 0; i < 26; ++i) {         if (t[v][i] != -1 && mx < sz[t[v][i]]) {           mx = sz[t[v][i]];           mxx = i;         }       }       if (mxx == -1) {         return;       }       res[p]++;       for (int i = 0; i < 26; ++i) {         if (i == mxx) continue;         if (t[v][i] != -1) {           res[p] += mrg(t[v][i], t[v][mxx]);         }       }       while (st.size()) {         t[st.top().first][st.top().second] = -1;         st.pop();       }     }     void get_all(int v, int p) {       get(v, p);       for (int i = 0; i < 26; ++i) {         if (t[v][i] != -1) {           get_all(t[v][i], p + 1);         }       }     }   };   bor br;   int n;   int main() {     cin >> n;     for (int i = 0; i < n - 1; ++i) {       int a, b;       char c;       cin >> a >> b >> c;       br.add(a - 1, b - 1, c);     }     br.get_sz(0);     br.get_all(0, 0);     int mx = 0, mxx = 0;     for (int i = 0; i < n; ++i) {       if (mx < br.res[i]) {         mx = br.res[i];         mxx = i;       }     }     cout << n - mx << endl << mxx + 1 << endl;     return 0;   }   