#include <bits/stdc++.h>
using namespace std;
const int N = 300005, Mod = 1000000007, Mod2 = 1000696969;
set<pair<int, int> > st[N];
vector<int> child[N];
int n, res, cnt, val[N];
char s[N];
void dfs(int u, int x, pair<int, int> pref) {
  pref.first = (26ll * pref.first + s[u]) % Mod;
  pref.second = (26ll * pref.second + s[u]) % Mod2;
  st[u].insert(pref);
  for (int v : child[u])
    if (v != x) {
      dfs(v, u, pref);
      if (st[v].size() > st[u].size()) st[v].swap(st[u]);
      for (auto cur : st[v]) st[u].insert(cur);
    }
  if (val[u] + st[u].size() > res) res = val[u] + st[u].size(), cnt = 0;
  if (val[u] + st[u].size() == res) ++cnt;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &val[i]);
  for (int i = 1; i <= n; ++i) scanf(" %c", &s[i]);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    child[u].push_back(v);
    child[v].push_back(u);
  }
  dfs(1, 1, make_pair(0, 0));
  printf("%d\n%d\n", res, cnt);
}
