#include <bits/stdc++.h>
using namespace std;
const int maxn = 300005;
int n, fst[maxn], to[maxn << 1], nxt[maxn << 1], tt, c[maxn], dif[maxn];
char s[maxn];
struct node {
  node *ch[26];
  int size;
} po[maxn], *pn = po;
node *T[maxn];
void merge(node *a, node *b) {
  for (int i = 0; i < 26; ++i)
    if (b->ch[i]) {
      if (!a->ch[i]) {
        a->ch[i] = b->ch[i];
        a->size += a->ch[i]->size;
      } else {
        a->size -= a->ch[i]->size;
        merge(a->ch[i], b->ch[i]);
        a->size += a->ch[i]->size;
      }
    }
}
void dfs(int x, int fa) {
  int p = -1;
  for (int i = fst[x]; i; i = nxt[i])
    if (to[i] != fa) {
      dfs(to[i], x);
      if (p == -1 || T[to[i]]->size > T[p]->size) p = to[i];
    }
  T[x] = ++pn;
  if (p == -1) {
    T[x]->size = 1;
    dif[x] = 1;
    return;
  }
  T[x]->ch[s[p] - 97] = T[p];
  T[x]->size = T[p]->size + 1;
  for (int i = fst[x]; i; i = nxt[i])
    if (to[i] != fa && to[i] != p) {
      node *&t = T[x]->ch[s[to[i]] - 97];
      if (!t) {
        T[x]->size += (t = T[to[i]])->size;
        continue;
      }
      T[x]->size -= t->size;
      merge(t, T[to[i]]);
      T[x]->size += t->size;
    }
  dif[x] = T[x]->size;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &c[i]);
  scanf("%s", s + 1);
  for (int i = 1, x, y; i < n; ++i) {
    scanf("%d%d", &x, &y);
    nxt[++tt] = fst[x];
    fst[x] = tt;
    to[tt] = y;
    nxt[++tt] = fst[y];
    fst[y] = tt;
    to[tt] = x;
  }
  dfs(1, 1);
  int ans = 0, cnt = 0;
  for (int i = 1; i <= n; ++i)
    if (c[i] + dif[i] > ans)
      ans = c[i] + dif[i], cnt = 1;
    else if (c[i] + dif[i] == ans)
      ++cnt;
  printf("%d\n%d\n", ans, cnt);
  return 0;
}
