#include <bits/stdc++.h>
using namespace std;
int read() {
  char c;
  int s = 0, t = 1;
  while (!isdigit(c = getchar()))
    if (c == '-') t = -1;
  do {
    s = s * 10 + c - '0';
  } while (isdigit(c = getchar()));
  return s * t;
}
const int maxn = 300010;
int n, tot, ans = 0, ansnum = 0, num[maxn], first[maxn], ch[maxn][30], sz[maxn];
char s[maxn];
struct edge {
  int v, from;
} e[maxn * 2];
void insert(int u, int v) {
  tot++;
  e[tot].v = v;
  e[tot].from = first[u];
  first[u] = tot;
}
int merge(int a, int b) {
  int x = s[b] - 'a', sum;
  if (ch[a][x]) {
    sum = 1;
    for (int i = 0; i < 26; i++)
      if (ch[b][i]) sum += merge(ch[a][x], ch[b][i]);
  } else {
    sum = 0;
    ch[a][x] = b;
  }
  return sum;
}
void dfs(int x, int fa) {
  sz[x] = 1;
  for (int i = first[x]; i; i = e[i].from)
    if (e[i].v != fa) {
      dfs(e[i].v, x);
      sz[x] += sz[e[i].v];
      sz[x] -= merge(x, e[i].v);
    }
  if (ans < num[x] + sz[x]) {
    ans = num[x] + sz[x];
    ansnum = 1;
  } else if (ans == num[x] + sz[x])
    ansnum++;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) num[i] = read();
  scanf("%s", s + 1);
  for (int i = 1; i < n; i++) {
    int u = read(), v = read();
    insert(u, v);
    insert(v, u);
  }
  dfs(1, 0);
  printf("%d\n%d", ans, ansnum);
  return 0;
}
