#include <bits/stdc++.h>
using namespace std;
const int N = 300003;
vector<int> a[N];
int add[N];
int size[N];
char lab[N];
int n;
bool incLab(int u, int v) { return lab[u] < lab[v]; }
void dfsInit(int u, int p) {
  if (p) a[u].erase(find(a[u].begin(), a[u].end(), p));
  for (int v : a[u]) dfsInit(v, u);
}
void dfsMerge(int u) {
  sort(a[u].begin(), a[u].end(), incLab);
  vector<int> newSons;
  for (int i = 0, j; i < a[u].size(); i = j + 1) {
    j = i;
    while (j + 1 < a[u].size() && lab[a[u][i]] == lab[a[u][j + 1]]) ++j;
    for (int k = i + 1; k <= j; ++k) {
      a[a[u][i]].insert(a[a[u][i]].end(), a[a[u][k]].begin(), a[a[u][k]].end());
      a[a[u][k]].clear();
    }
    newSons.push_back(a[u][i]);
    if (i < j) dfsMerge(a[u][i]);
  }
  a[u] = newSons;
  size[u] = 1;
  for (int v : a[u]) size[u] += size[v];
}
int ans = 0, cnt = 0;
void dfsCalc(int u) {
  for (int v : a[u]) dfsCalc(v);
  dfsMerge(u);
  int now = size[u] + add[u];
  if (ans < now) {
    ans = now;
    cnt = 1;
  } else if (ans == now) {
    ++cnt;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> add[i];
  cin >> (lab + 1);
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  dfsInit(1, 0);
  dfsCalc(1);
  cout << ans << endl << cnt << endl;
  return 0;
}
