#include <bits/stdc++.h>
using namespace std;
int a[320000][30];
int n, c[320000];
int cc[320000];
int x1, x2;
int ed, st[320000];
struct node {
  int to, next;
} g[620000];
inline void add(int x, int y) {
  ed++;
  g[ed].to = y;
  g[ed].next = st[x];
  st[x] = ed;
}
int siz[320000];
inline void merge(int x, int y) {
  for (int i = 1; i <= 26; i++) {
    if (a[y][i] != 0) {
      if (a[x][i] == 0) {
        a[x][i] = a[y][i];
        siz[x] += siz[a[x][i]];
      } else {
        siz[x] -= siz[a[x][i]];
        merge(a[x][i], a[y][i]);
        siz[x] += siz[a[x][i]];
      }
    }
  }
}
char str[320000];
int ans, cnt;
inline void dfs(int x, int y) {
  siz[x] = 1;
  for (int i = st[x]; i != 0; i = g[i].next) {
    if (g[i].to != y) {
      dfs(g[i].to, x);
      if (a[x][cc[g[i].to]] == 0) {
        a[x][cc[g[i].to]] = g[i].to;
        siz[x] += siz[g[i].to];
      } else {
        siz[x] -= siz[a[x][cc[g[i].to]]];
        merge(a[x][cc[g[i].to]], g[i].to);
        siz[x] += siz[a[x][cc[g[i].to]]];
      }
    }
  }
  if (siz[x] + c[x] > ans) {
    ans = siz[x] + c[x];
    cnt = 0;
  }
  if (siz[x] + c[x] == ans) {
    cnt++;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
  }
  scanf("%s", str + 1);
  for (int i = 1; i <= n; i++) {
    cc[i] = str[i] - 'a' + 1;
  }
  for (int i = 1; i < n; i++) {
    scanf("%d %d", &x1, &x2);
    add(x1, x2);
    add(x2, x1);
  }
  dfs(1, 0);
  printf("%d\n%d\n", ans, cnt);
  return 0;
}
