#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 35, m1 = 1e9 + 51, m2 = 1e9 + 123;
int hash1[N], hash2[N], a[N], pos[N], val[N];
int n, u, v;
string t;
vector<int> G[N];
set<pair<int, int> > s[N];
void dfs(int u, int p) {
  pos[u] = u;
  for (int i = 0; i < G[u].size(); ++i) {
    int v = G[u][i];
    if (v == p) continue;
    hash1[v] = (hash1[u] * 26LL % m1 + t[v - 1] - 'a' + 1) % m1;
    hash2[v] = (hash2[u] * 26LL % m2 + t[v - 1] - 'a' + 1) % m2;
    dfs(v, u);
    if (s[pos[u]].size() < s[pos[v]].size()) pos[u] = pos[v];
  }
  s[pos[u]].insert(pair<int, int>(hash1[u], hash2[u]));
  for (int i = 0; i < G[u].size(); ++i) {
    int v = G[u][i];
    if (v == p || pos[v] == pos[u]) continue;
    set<pair<int, int> >::iterator it;
    for (it = s[pos[v]].begin(); it != s[pos[v]].end(); ++it) {
      s[pos[u]].insert(*it);
    }
  }
  val[u] = s[pos[u]].size() + a[u];
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  cin >> t;
  for (int i = 1; i < n; ++i) {
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  hash1[1] = hash2[1] = t[0] - 'a' + 1;
  dfs(1, 1);
  int Max = 0, Cnt = 0;
  for (int i = 1; i <= n; ++i) {
    if (val[i] > Max) {
      Max = val[i];
      Cnt = 1;
    } else if (val[i] == Max)
      Cnt++;
  }
  cout << Max << '\n' << Cnt;
}
