#include <bits/stdc++.h>
using namespace std;
struct cww {
  cww() {
    if (1) {
      ios::sync_with_stdio(false);
      cin.tie(0);
    }
  }
} star;
template <typename T>
inline void chmin(T &l, T r) {
  l = min(l, r);
}
template <typename T>
inline void chmax(T &l, T r) {
  l = max(l, r);
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &it : v) is >> it;
  return is;
}
inline unsigned long long xor64(unsigned long long x) {
  for (int i = (0); i < (2); i++) x = x ^ (x << 13);
  x = x ^ (x >> 7);
  x = x ^ (x << 17);
  return x;
}
namespace myhash {
const int Bsizes[] = {3,  9,  13, 17, 21, 25, 29, 33, 37, 41,
                      45, 49, 53, 57, 61, 65, 69, 73, 77, 81};
const int xor_nums[] = {0x100007d1, 0x5ff049c9, 0x14560859, 0x07087fef,
                        0x3e277d49, 0x4dba1f17, 0x709c5988, 0x05904258,
                        0x1aa71872, 0x238819b3, 0x7b002bb7, 0x1cf91302,
                        0x0012290a, 0x1083576b, 0x76473e49, 0x3d86295b,
                        0x20536814, 0x08634f4d, 0x115405e8, 0x0e6359f2};
const int hash_key = xor_nums[rand() % 20];
const int mod_key = xor_nums[rand() % 20];
template <typename T>
struct myhash {
  std::size_t operator()(const T &val) const { return xor64(val) ^ hash_key; }
};
};  // namespace myhash
template <typename T, typename U>
class myhash_map : public std::unordered_map<T, U, myhash::myhash<T>> {
 public:
  using MAP = std::unordered_map<T, U, myhash::myhash<T>>;
  myhash_map() : MAP() { MAP::rehash(myhash::Bsizes[rand() % 20]); }
};
const unsigned long long h[3] = {90001, 1000003, 937919};
struct superhash {
  unsigned long long v[3];
  superhash() {
    for (int i = 0; i < 3; i++) v[i] = 0;
  }
  void add(int k) {
    for (int i = 0; i < 3; i++) {
      v[i] *= h[i];
      v[i] += k;
    }
  }
  unsigned long long getullhash() {
    unsigned long long res = 1145141919;
    for (int i = 0; i < 3; i++) {
      res = res xor v[i];
    }
    return res;
  }
};
int N;
vector<vector<int>> g;
char C[312345];
void chiwawa() {
  cin >> N;
  g.resize(N + 1);
  for (int i = (0); i < (N - 1); i++) {
    int a, b;
    cin >> a >> b;
    cin >> C[b];
    g[a].push_back(b);
  }
}
inline int latte(vector<pair<int, superhash>> &now) {
  myhash_map<unsigned long long, int> cnt;
  vector<pair<int, superhash>> nxt;
  for (auto &it : now) {
    cnt[it.second.getullhash()]++;
  }
  for (auto &it : now) {
    if (cnt[it.second.getullhash()] >= 2) nxt.push_back(it);
  }
  swap(now, nxt);
  int ret = 0;
  for (auto &it : cnt) ret += it.second - 1;
  return ret;
}
int skiptest(vector<pair<int, superhash>> &in) {
  int res = 0;
  vector<pair<int, superhash>> now;
  for (auto &v : in) {
    for (auto &u : g[v.first]) {
      res++;
      for (auto &s : g[u]) {
        pair<int, superhash> unko(s, v.second);
        unko.second.add(C[s]);
        now.push_back(unko);
      }
    }
  }
  if (0) cout << "skip:" << endl;
  res += latte(now);
  while (now.size()) {
    vector<pair<int, superhash>> nxt;
    for (auto &v : now) {
      if (0) cout << v.first << "(" << v.second.getullhash() << ") ";
      for (auto &u : g[v.first]) {
        pair<int, superhash> unko(u, v.second);
        unko.second.add(C[u]);
        nxt.push_back(unko);
      }
    }
    if (0) cout << endl;
    res += latte(nxt);
    swap(now, nxt);
  }
  if (0) cout << "skipend:" << res << endl;
  return res;
}
int main() {
  chiwawa();
  vector<pair<int, superhash>> now;
  now.push_back(pair<int, superhash>(1, superhash()));
  int depth = 0;
  auto res = make_pair(N, 1);
  while (now.size()) {
    depth++;
    chmin(res, make_pair(N - skiptest(now), depth));
    vector<pair<int, superhash>> nxt;
    if (0) cout << depth << " ";
    for (auto &v : now) {
      if (0) cout << v.first << " ";
      for (auto &u : g[v.first]) {
        pair<int, superhash> unko(u, v.second);
        unko.second.add(C[u]);
        nxt.push_back(unko);
      }
    }
    if (0) cout << endl;
    swap(now, nxt);
  }
  cout << res.first << endl;
  cout << res.second << endl;
  return 0;
}
