#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int N = 5e5 + 5;
vector<pair<int, char>> g[N];
int par[N];
vector<int> w[N];
void dfs(int v, int p = -1, int h = 1) {
  par[v] = p;
  w[h].push_back(v);
  for (auto e : g[v]) {
    int i = e.first;
    if (i != p) dfs(i, v, h + 1);
  }
}
const int X1 = 277;
const int X2 = 227;
const int M1 = 1777777777;
const int M2 = 1444444447;
int inv(int a, int mod) {
  if (a == 1) return 1;
  return mod - mod * 1LL * inv(mod % a, a) / a;
}
set<ll> q[N];
int add1[N], mul1[N];
int add2[N], mul2[N];
vector<pair<int, ll>> undo;
bool mem;
void insto(int i, ll x) {
  ll x1 = x >> 32;
  ll x2 = x & ((1LL << 32) - 1);
  x1 = (x1 - add1[i] + M1) * 1LL * inv(mul1[i], M1) % M1;
  x2 = (x2 - add2[i] + M2) * 1LL * inv(mul2[i], M2) % M2;
  x = x1 << 32 | x2;
  if (!q[i].count(x)) {
    q[i].insert(x);
    if (mem) undo.push_back({i, x});
  }
}
void doswap(int i, int j) {
  q[i].swap(q[j]);
  swap(add1[i], add1[j]);
  swap(add2[i], add2[j]);
  swap(mul1[i], mul1[j]);
  swap(mul2[i], mul2[j]);
}
void merge(int i, int j) {
  if (q[i].size() < q[j].size()) {
    doswap(i, j);
    if (mem) undo.push_back({-i - 1, -j - 1});
  }
  for (ll x : q[j]) {
    ll x1 = x >> 32;
    ll x2 = x & ((1LL << 32) - 1);
    x1 = (x1 * 1LL * mul1[j] + add1[j]) % M1;
    x2 = (x2 * 1LL * mul2[j] + add2[j]) % M2;
    x = x1 << 32 | x2;
    insto(i, x);
  }
}
void doadd(int i, int a) {
  add1[i] = (add1[i] + a) % M1;
  add2[i] = (add2[i] + a) % M2;
}
void domul1(int i, int m) {
  mul1[i] = mul1[i] * 1LL * m % M1;
  add1[i] = add1[i] * 1LL * m % M1;
}
void domul2(int i, int m) {
  mul2[i] = mul2[i] * 1LL * m % M2;
  add2[i] = add2[i] * 1LL * m % M2;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n;
  for (int k = 0; k < n - 1; ++k) {
    int a, b;
    string c;
    cin >> a >> b >> c;
    --a;
    --b;
    g[a].push_back({b, c[0]});
    g[b].push_back({a, c[0]});
  }
  dfs(0);
  vector<int> ans(n + 2);
  for (int i = 0; i < n; ++i) mul1[i] = mul2[i] = 1;
  for (int h = n; h > 0; --h) {
    for (int v : w[h]) {
      mem = true;
      int total = 0;
      for (auto e : g[v])
        if (e.first != par[v]) {
          int i = e.first;
          total += q[i].size();
          merge(v, i);
        }
      ans[h + 1] += total - q[v].size() + 1;
      if (!q[v].count(0)) --ans[h + 1];
      while (undo.size()) {
        auto p = undo.back();
        undo.pop_back();
        int i = p.first;
        if (i < 0) {
          int j = p.second;
          doswap(-i - 1, -j - 1);
        } else {
          ll x = p.second;
          q[i].erase(x);
        }
      }
      mem = false;
      for (auto e : g[v])
        if (e.first != par[v]) {
          int i = e.first;
          domul1(i, X1);
          domul2(i, X2);
          doadd(i, e.second);
          merge(v, i);
          q[i].clear();
        }
      insto(v, 0);
    }
  }
  pair<int, int> res = {n, 0};
  for (int i = 1; i <= n; ++i) res = min(res, {n - ans[i], i - 1});
  cout << res.first << endl << res.second << endl;
  return 0;
}
