#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)3e5 + 5;
const int mod1 = (int)1e9 + 7;
const int mod2 = (int)1e9 + 9;
const int base = 413;
const long long inf = 1LL << 50;
int n, c[maxn], dif[maxn];
pair<long long, long long> H[maxn];
vector<int> G[maxn];
int sz[maxn];
string a;
set<pair<long long, long long> > S;
void calc(int u, int pu) {
  H[u].first = (H[pu].first * base + (a[u] - 'a' + 1)) % mod1;
  H[u].second = (H[pu].second * base + (a[u] - 'a' + 1)) % mod2;
  sz[u] = 1;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == pu) continue;
    calc(v, u);
    sz[u] += sz[v];
  }
}
void ins(int u, int pu) {
  S.insert(H[u]);
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == pu) continue;
    ins(v, u);
  }
}
void dfs(int u, int pu) {
  int id = -1, mx = -1;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == pu) continue;
    if (sz[v] > mx) {
      mx = sz[v];
      id = v;
    }
  }
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == pu || v == id) continue;
    dfs(v, u);
    S.clear();
  }
  if (id != -1) dfs(id, u);
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == pu || v == id) continue;
    ins(v, u);
  }
  S.insert(H[u]);
  dif[u] = S.size();
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> c[i];
  cin >> a;
  a = 'a' + a;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  calc(1, 0);
  dfs(1, 0);
  int mx = 0, cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (dif[i] + c[i] > mx) {
      mx = dif[i] + c[i];
      cnt = 1;
    } else if (dif[i] + c[i] == mx)
      cnt++;
  }
  cout << mx << endl << cnt << endl;
}
