#include <bits/stdc++.h>
using namespace std;
int n, x, y, ans, cnt, v[301000], f[301000], ch[301000][26];
vector<int> a[301000];
char s[301000];
void merge(int &x, int y) {
  if (x == 0) {
    x = y;
    return;
  }
  for (int c = 0; c < 26; c++) {
    int &xx = ch[x][c], yy = ch[y][c];
    if (!yy) continue;
    f[x] -= f[xx];
    merge(xx, yy);
    f[x] += f[xx];
  }
}
void dfs(int x, int p) {
  f[x] = 1;
  for (int i = 0; i < a[x].size(); i++) {
    int y = a[x][i];
    if (y == p) continue;
    dfs(y, x);
    int c = s[y];
    f[x] -= f[ch[x][c]];
    merge(ch[x][c], y);
    f[x] += f[ch[x][c]];
  }
  if (f[x] + v[x] > ans) {
    ans = f[x] + v[x];
    cnt = 1;
  } else if (f[x] + v[x] == ans)
    cnt++;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &v[i]);
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) s[i] -= 'a';
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    a[x].push_back(y);
    a[y].push_back(x);
  }
  dfs(1, 0);
  printf("%d\n%d\n", ans, cnt);
}
