#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int n;
int C[N];
int str[N];
int first[N], tot;
struct Edge {
  int y, nex;
} edge[N << 1];
void addedge(int x, int y) {
  edge[tot] = (Edge){y, first[x]};
  first[x] = tot++;
}
int f[N][26];
int sum[N];
int ans = 0, num = 0;
int merge(int x, int y) {
  if (x == -1) return y;
  if (y == -1) return x;
  for (int i = 0; i < 26; ++i) f[x][i] = merge(f[x][i], f[y][i]);
  sum[x] = 1;
  for (int i = 0; i < 26; ++i)
    if (f[x][i] != -1) sum[x] += sum[f[x][i]];
  return x;
}
void dfs(int x, int fa) {
  memset(f[x], -1, sizeof(f[x]));
  sum[x] = 1;
  for (int k = first[x]; k != -1; k = edge[k].nex) {
    int y = edge[k].y;
    if (y == fa) continue;
    dfs(y, x);
    f[x][str[y]] = merge(f[x][str[y]], y);
  }
  sum[x] = 1;
  for (int i = 0; i < 26; ++i)
    if (f[x][i] != -1) sum[x] += sum[f[x][i]];
  if (sum[x] + C[x] > ans)
    ans = sum[x] + C[x], num = 1;
  else if (sum[x] + C[x] == ans) {
    ++num;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &C[i]);
  for (int i = 1; i <= n; ++i) {
    while (str[i] = getchar(), !isalpha(str[i]))
      ;
    str[i] = str[i] - 'a';
  }
  memset(first, -1, sizeof(first));
  tot = 0;
  for (int i = 1; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    addedge(x, y);
    addedge(y, x);
  }
  dfs(1, 0);
  printf("%d\n%d\n", ans, num);
  return 0;
}
