#include <bits/stdc++.h>
using namespace std;
const int SIZE = 300300;
vector<pair<int, char> > g[SIZE];
int h[SIZE], tin[SIZE], tout[SIZE], s[SIZE], t[SIZE * 2], tim = -1;
int ansh[SIZE];
char g1[SIZE];
int bor[SIZE * 2][27];
int tv = 1, root = 0;
vector<pair<int, int> > otk;
void print(int v) {
  cout << v << "\n";
  for (int i = 0; i < 27; i++) {
    if (bor[v][i] != -1) {
      cout << char(i + 'a') << " " << bor[v][i] << "\n";
    }
  }
  for (int i = 0; i < 27; i++) {
    if (bor[v][i] != -1) {
      print(bor[v][i]);
    }
  }
}
void dfs2(int v, int w, int maxv) {
  for (auto u : g[v]) {
    if (u.first == maxv) {
      continue;
    }
    int y = u.second - 'a';
    if (bor[w][y] == -1) {
      bor[w][y] = tv;
      otk.push_back({w, y});
      tv++;
    }
    dfs2(u.first, bor[w][y], maxv);
  }
}
void merg(int v) {
  int u1 = v, u2 = root;
  dfs2(u1, u2, -1);
}
void dfs1(int v, int e) {
  h[v] = e;
  tim++;
  tin[v] = tim;
  s[v] = 1;
  for (auto u : g[v]) {
    dfs1(u.first, e + 1);
    s[v] += s[u.first];
  }
  tout[v] = tim;
}
void dfs(int v, bool keep) {
  int maxv = -1, maxs = 0;
  for (auto u : g[v]) {
    if (s[u.first] > maxs) {
      maxs = s[u.first];
      maxv = u.first;
    }
  }
  for (auto u : g[v]) {
    if (u.first != maxv) {
      dfs(u.first, 0);
    }
  }
  if (maxv != -1) {
    dfs(maxv, 1);
  }
  for (auto u : g[v]) {
    if (u.first == maxv) {
      continue;
    }
    merg(u.first);
  }
  ansh[h[v] + 1] += (tv - s[v]);
  if (!keep) {
    for (int i = 0; i <= tv; i++) {
      for (int j = 0; j < 27; j++) {
        bor[i][j] = -1;
      }
    }
    tv = 1;
    root = 0;
  } else {
    if (maxv != -1) {
      for (auto w : otk) {
        bor[w.first][w.second] = -1;
        tv--;
      }
      bor[tv][g1[maxv]] = root;
      root = tv;
      tv++;
      dfs2(v, root, maxv);
    }
  }
  otk.clear();
}
int main() {
  for (int i = 0; i < SIZE * 2; i++) {
    for (int j = 0; j < 27; j++) {
      bor[i][j] = -1;
    }
  }
  int n, a, b;
  char x;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b >> x;
    g[a - 1].push_back({b - 1, x});
    g1[b - 1] = x - 'a';
  }
  for (int i = 0; i < SIZE; i++) {
    ansh[i] = n;
  }
  dfs1(0, 0);
  dfs(0, 1);
  int mans = 1e9, mi = -1;
  for (int i = 0; i < SIZE; i++) {
    if (ansh[i] < mans) {
      mans = ansh[i];
      mi = i;
    }
  }
  cout << mans << " " << mi;
  return 0;
}
