#include <bits/stdc++.h>
using namespace std;
template <typename T>
T getint() {
  T x = 0, p = 1;
  char ch;
  do {
    ch = getchar();
  } while (ch <= ' ');
  if (ch == '-') p = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * p;
}
template <typename T1, typename T2>
bool umin(T1 &x, const T2 &y) {
  if (x > y) return x = y, true;
  return false;
}
template <typename T1, typename T2>
bool umax(T1 &x, const T2 &y) {
  if (x < y) return x = y, true;
  return false;
}
const int maxn = (int)6e5 + 10;
const int inf = (int)1e9 + 5;
const int mod = (int)1e9 + 7;
const long long llinf = (long long)1e18 - 1;
const long double pi = acos(-1.0);
map<int, int> nxt[maxn];
bool leaf[maxn];
int diff[maxn];
int c[maxn];
char s[maxn];
int n;
vector<int> g[maxn];
int sz[maxn];
int root[maxn];
int T = 1;
int calc(int v) {
  int ret = leaf[v];
  for (auto i : nxt[v])
    if (nxt[v][i.first]) ret += calc(nxt[v][i.first]);
  return ret;
}
void addTrie(int globroot, int root, int v) {
  for (int c = (0); c < (26); c++) {
    if (nxt[v][c] == 0) continue;
    if (nxt[root][c] == 0) {
      diff[globroot] += calc(nxt[v][c]);
      nxt[root][c] = nxt[v][c];
      continue;
    }
    diff[globroot] += leaf[nxt[v][c]] - leaf[nxt[root][c]];
    leaf[nxt[root][c]] |= leaf[nxt[v][c]];
    addTrie(globroot, nxt[root][c], nxt[v][c]);
  }
}
void dfs(int v, int par = -1) {
  sz[v] = 1;
  int chi = -1;
  for (int x : g[v]) {
    if (x == par) continue;
    dfs(x, v);
    sz[v] += sz[x];
    if (chi == -1 || sz[x] > sz[chi]) {
      chi = x;
    }
  }
  int &rt = root[v];
  rt = T++;
  int &link = nxt[rt][s[v] - 'a'];
  if (chi != -1) {
    link = root[chi];
    diff[rt] += diff[link];
    for (int x : g[v]) {
      if (x == par || x == chi) continue;
      addTrie(rt, link, root[x]);
    }
  } else {
    link = T++;
  }
  leaf[link] = true;
  diff[rt]++;
  c[v] += diff[rt];
}
int main() {
  scanf("%d", &n);
  for (int i = (0); i < (n); i++) scanf("%d", c + i);
  gets(s);
  gets(s);
  for (int i = (0); i < (n - 1); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x;
    --y;
    g[x].push_back(y), g[y].push_back(x);
  }
  dfs(0, -1);
  int mx = c[0] + diff[0], cnt = 1;
  for (int i = (1); i < (n); i++) {
    int val = c[i];
    if (val > mx) mx = val, cnt = 0;
    if (val == mx) cnt++;
  }
  printf("%d\n%d\n", mx, cnt);
  return 0;
}
