#include <bits/stdc++.h>
using namespace std;
int n;
int c[300005];
char s[300005];
vector<int> v[300005];
struct Trie {
  Trie *s[26];
  int sz;
  Trie() {
    for (int i = 0; i < 26; i++) s[i] = nullptr;
    sz = 1;
  }
} * t[300005];
int msize(Trie *x) {
  if (x == nullptr)
    return 0;
  else
    return x->sz;
}
Trie *merge(Trie *x, Trie *y) {
  if (x == nullptr) return y;
  if (y == nullptr) return x;
  int tsz = 1;
  for (int i = 0; i < 26; i++) {
    x->s[i] = merge(x->s[i], y->s[i]);
    tsz += msize(x->s[i]);
  }
  x->sz = tsz;
  delete y;
  return x;
}
void init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  scanf("%s", s + 1);
  for (int i = 1, a, b; i < n; i++) {
    scanf("%d%d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) t[i] = new Trie();
}
int ans, aidx;
bool vs[300005];
void dfs(int x) {
  vs[x] = true;
  for (int y : v[x])
    if (!vs[y]) {
      dfs(y);
      t[x]->s[s[y] - 'a'] = merge(t[x]->s[s[y] - 'a'], t[y]);
    }
  for (int i = 0; i < 26; i++) {
    t[x]->sz += msize(t[x]->s[i]);
  }
  int tmp = t[x]->sz + c[x];
  if (tmp == ans)
    aidx++;
  else if (tmp > ans)
    ans = tmp, aidx = 1;
}
void process() {
  ans = 0, aidx = 0;
  dfs(1);
  printf("%d\n%d\n", ans, aidx);
}
int main() {
  init();
  process();
  return 0;
}
