#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:20000000")
using namespace std;
int ri() {
  int x;
  scanf("%d", &x);
  return x;
}
long long rll() {
  long long x;
  scanf("%lld", &x);
  return x;
}
struct tree {
  int start;
  vector<map<int, int> > mas;
  void addBack() { mas.push_back(map<int, int>()); }
  int size() { return mas.size(); }
};
int c[300500];
char s[300500];
vector<vector<int> > graph;
int result[300500];
tree *tr[300500];
void mergeTree(tree &a, tree &b) {
  queue<pair<int, int> > st;
  st.push(make_pair(a.start, b.start));
  while (!st.empty()) {
    int posA = st.front().first;
    int posB = st.front().second;
    st.pop();
    for (map<int, int>::iterator it = b.mas[posB].begin();
         it != b.mas[posB].end(); it++) {
      map<int, int>::iterator j = a.mas[posA].find(it->first);
      int nxt;
      if (j == a.mas[posA].end()) {
        a.addBack();
        a.mas[posA][it->first] = a.size() - 1;
        nxt = a.size() - 1;
      } else
        nxt = j->second;
      st.push(make_pair(nxt, it->second));
    }
  }
}
void go(int v, int parent) {
  for (int i = 0; i < graph[v].size(); i++) {
    int to = graph[v][i];
    if (to == parent) continue;
    go(to, v);
    if (!tr[v])
      tr[v] = tr[to];
    else {
      if (tr[v]->size() < tr[to]->size()) swap(tr[v], tr[to]);
      mergeTree(*tr[v], *tr[to]);
    }
  }
  if (!tr[v]) {
    int w = s[v] - 'a';
    tr[v] = new tree();
    tr[v]->addBack();
    tr[v]->mas[0][w] = 1;
    tr[v]->addBack();
    tr[v]->start = 0;
  } else {
    int w = s[v] - 'a';
    tr[v]->addBack();
    int oldStart = tr[v]->start;
    tr[v]->start = tr[v]->mas.size() - 1;
    tr[v]->mas[tr[v]->start][w] = oldStart;
  }
  result[v] = tr[v]->mas.size() - 1;
}
void solve() {
  int n = ri();
  for (int i = (int)(1); i <= (int)(n); i++) c[i] = ri();
  gets(s);
  gets(s + 1);
  graph.resize(n + 1);
  for (int i = (int)(2); i <= (int)(n); i++) {
    int a = ri(), b = ri();
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  go(1, -1);
  int res = -1, cntt = 0;
  for (int i = (int)(1); i <= (int)(n); i++)
    if (result[i] + c[i] > res)
      res = result[i] + c[i], cntt = 1;
    else if (result[i] + c[i] == res)
      cntt++;
  printf("%d\n%d", res, cntt);
}
int main() {
  solve();
  return 0;
}
