#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
const int N = 300000;
using namespace std;
int n, m;
vector<vector<int> > gr;
int c[N];
string st;
long long ans[N], en = 0, best;
long long siz[N];
long long est[N];
long long tri[N][26];
long long bound(int u, int v) {
  long long ans = 0;
  for (int i = 0; i < 26; ++i) {
    if (tri[u][i] && tri[v][i]) {
      ans += bound(tri[u][i], tri[v][i]);
    } else {
      if (tri[v][i]) {
        tri[u][i] = tri[v][i];
        ans += siz[tri[v][i]];
      }
    }
  }
  siz[u] += ans;
  return ans;
}
void dfs(int u, int p) {
  for (int i = 0; i < gr[u].size(); ++i) {
    int to = gr[u][i];
    if (to == p) continue;
    dfs(to, u);
  }
  long long sz = 1;
  for (int i = 0; i < gr[u].size(); ++i) {
    int to = gr[u][i];
    if (to == p) continue;
    if (tri[u][st[to] - 'a']) {
      sz += bound(tri[u][st[to] - 'a'], to);
    } else {
      tri[u][st[to] - 'a'] = to;
      sz += siz[to];
    }
  }
  est[u] = sz;
  siz[u] = sz;
}
void solve() {
  cin >> n;
  gr.resize(n);
  for (int i = 0; i < n; ++i) cin >> c[i];
  cin >> st;
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    gr[u].push_back(v);
    gr[v].push_back(u);
  }
  dfs(0, 0);
  for (int i = 0; i < n; ++i) {
    if (c[i] + est[i] == best) en++;
    if (c[i] + est[i] > best) {
      best = c[i] + est[i];
      en = 1;
    }
  }
  cout << best << '\n' << en;
}
int main() {
  srand(1337);
  solve();
  return 0;
}
