#include <bits/stdc++.h>
template <typename T>
inline T abs(T a) {
  return a < 0 ? -a : a;
}
template <typename T>
inline T min(T a, T b) {
  return a < b ? a : b;
}
template <typename T>
inline T max(T a, T b) {
  return a > b ? a : b;
}
template <typename T>
inline void swap(T& a, T& b) {
  T t = a;
  a = b, b = t;
}
template <typename T>
inline bool umin(T& mn, T u) {
  return u < mn ? mn = u, true : false;
}
template <typename T>
inline bool umax(T& mx, T u) {
  return u > mx ? mx = u, true : false;
}
template <typename T>
inline void read(T& r) {
  char c;
  r = 0;
  bool flag = false;
  do c = getchar();
  while (c != '-' && (c < '0' || c > '9'));
  if (c == '-') flag = true, c = getchar();
  do r = r * 10 + c - '0', c = getchar();
  while (c >= '0' && c <= '9');
  if (flag) r *= -1;
}
template <typename T1, typename T2>
inline void read(T1& r, T2& s) {
  read(r), read(s);
}
template <typename T1, typename T2, typename T3>
inline void read(T1& r, T2& s, T3& t) {
  read(r), read(s), read(t);
}
template <typename T1, typename T2, typename T3, typename T4>
inline void read(T1& r, T2& s, T3& t, T4& u) {
  read(r), read(s), read(t), read(u);
}
template <typename T>
inline void write(T w, const char* c = "") {
  if (w == 0)
    putchar('0');
  else {
    if (w < 0) putchar('-'), w *= -1;
    static int s[21], top;
    top = 0;
    while (w) s[top++] = w % 10, w /= 10;
    while (top--) putchar(s[top] + '0');
  }
  for (int i = 0; c[i]; i++) putchar(c[i]);
}
struct ac {
  int to, nx;
} e[600000];
int L = 1, first[300001];
inline void addedge(int u, int v) {
  e[L].to = v, e[L].nx = first[u], first[u] = L++, e[L].to = u,
  e[L].nx = first[v], first[v] = L++;
}
char s[300001];
int val[300001], a[300001][26], cnt[300001], dfc, ans, anscnt;
int merge(int u, int v, int c) {
  int ret = 0;
  if (a[u][c]) {
    ++ret;
    for (int i = 0; i < 26; i++)
      if (a[v][i]) ret += merge(a[u][c], a[v][i], i);
  } else
    a[u][c] = v;
  return ret;
}
int dfs(int u, int f = 0) {
  int no = ++dfc, &xc = cnt[u] = 1;
  for (int j = first[u], v = e[j].to; j; j = e[j].nx, v = e[j].to)
    if (v != f) xc += -merge(no, dfs(v, u), s[v] - 'a'), xc += cnt[v];
  val[u] += xc;
  if (val[u] == ans)
    anscnt++;
  else if (val[u] > ans)
    ans = val[u], anscnt = 1;
  return no;
}
int main() {
  int n, i, u, v;
  read(n);
  for (i = 1; i <= n; i++) read(val[i]);
  scanf("%s", s + 1);
  for (i = 1; i < n; i++) read(u, v), addedge(u, v);
  dfs(1);
  printf("%d\n%d\n", ans, anscnt);
  return 0;
}
