#include <bits/stdc++.h>
using namespace std;
const int N = 300 * 1000 + 5;
vector<int> adj[N][26];
long long ANS[N], R[N];
string s;
vector<int> ADJ[N];
int c[N];
long long prune(int, int);
void merge(int x, int y) {
  for (int i = 0; i < (26); ++i)
    if (adj[y][i].size()) {
      if (adj[x][i].size()) R[x] -= R[adj[x][i][0]];
      adj[x][i].push_back(adj[y][i][0]);
      R[x] += prune(x, i);
    }
}
long long prune(int u, int x) {
  int y = adj[u][x][0];
  for (int i = 1; i < adj[u][x].size(); ++i) merge(y, adj[u][x][i]);
  adj[u][x].clear();
  adj[u][x].push_back(y);
  return R[y];
}
void dfs(int u, int p) {
  for (int i = 0; i < (ADJ[u].size()); ++i) {
    int v = ADJ[u][i];
    if (v == p) continue;
    adj[u][s[v] - 'a'].push_back(v);
    dfs(v, u);
  }
  long long res = 1;
  for (int i = 0; i < (26); ++i)
    if (adj[u][i].size()) res += prune(u, i);
  R[u] = res;
  ANS[u] = res + 1ll * c[u];
}
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < (n); ++i) cin >> c[i];
  cin >> s;
  for (int i = 0; i < (n - 1); ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    ADJ[a].push_back(b);
    ADJ[b].push_back(a);
  }
  dfs(0, -1);
  int ma = 0;
  for (int i = 0; i < (n); ++i)
    if (ANS[i] > ANS[ma]) ma = i;
  int cnt = 0;
  for (int i = 0; i < (n); ++i)
    if (ANS[i] == ANS[ma]) ++cnt;
  cout << ANS[ma] << "\n" << cnt << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
