#include <bits/stdc++.h>
using namespace std;
const int N = 300500;
struct Node {
  int size;
  map<char, Node*> go;
  Node() : size(1) {}
};
typedef Node* pNode;
int n;
int cost[N];
char let[N];
vector<int> go[N];
int ans_val, ans_cnt;
pNode dfs_merge(pNode big, pNode small) {
  for (auto e : small->go) {
    char c = e.first;
    pNode to = e.second;
    if (big->go.count(c) == 0)
      big->go[c] = to;
    else {
      big->size -= big->go[c]->size;
      big->go[c] = dfs_merge(big->go[c], to);
    }
    big->size += big->go[c]->size;
  }
  return big;
}
pNode merge(pNode a, pNode b) {
  if (a->size > b->size) return dfs_merge(a, b);
  return dfs_merge(b, a);
}
pNode dfs(int v, int p) {
  pNode root = new Node();
  for (int to : go[v]) {
    if (to == p) continue;
    pNode son = dfs(to, v);
    root = merge(root, son);
  }
  pNode new_root = new Node();
  new_root->go[let[v]] = root;
  new_root->size += root->size;
  root = new_root;
  int cur = root->size + cost[v];
  if (cur > ans_val) {
    ans_val = cur;
    ans_cnt = 1;
  } else if (cur == ans_val)
    ans_cnt++;
  return root;
}
void solve() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &cost[i]);
  scanf("%s", let);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    go[a].push_back(b);
    go[b].push_back(a);
  }
  ans_val = -1;
  dfs(0, -1);
  printf("%d\n%d\n", ans_val - 1, ans_cnt);
}
int main() {
  solve();
  return 0;
}
