#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> hash_value[300010];
int N;
char str[300010];
vector<int> AdjList[300010];
map<pair<long long, long long>, vector<int> > mp;
map<pair<long long, long long>, vector<int> >::iterator it;
int Parent[300010];
int level[300010];
int subtree[300010];
void dfs(int node, int dad, pair<long long, long long> upper, int depth) {
  level[node] = depth;
  Parent[node] = dad;
  hash_value[node] = pair<long long, long long>(
      (upper.first * 131 + str[node - 1]) % 1000000007,
      (upper.second * 239 + str[node - 1]) % 1000000009);
  mp[hash_value[node]].push_back(node);
  for (int i = 0; i < AdjList[node].size(); i++) {
    int v = AdjList[node][i];
    if (v != dad) {
      dfs(v, node, hash_value[node], depth + 1);
      subtree[node] += subtree[v];
    }
  }
  subtree[node]++;
}
int dp[300010][20];
void preprocess(void) {
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < 20; j++) dp[i][j] = -1;
  }
  for (int i = 1; i <= N; i++) {
    dp[i][0] = Parent[i];
  }
  for (int j = 1; (1 << j) <= N; j++) {
    for (int i = 1; i <= N; i++) {
      if (dp[i][j - 1] != -1) dp[i][j] = dp[dp[i][j - 1]][j - 1];
    }
  }
}
int lca(int p, int q) {
  if (level[p] < level[q]) swap(p, q);
  int foo;
  for (foo = 1; (1 << foo) <= level[p]; foo++)
    ;
  foo--;
  for (int i = foo; i >= 0; i--) {
    if (level[p] - (1 << i) >= level[q]) p = dp[p][i];
  }
  if (p == q) return p;
  for (int i = foo; i >= 0; i--) {
    if (dp[p][i] != -1 and dp[p][i] != dp[q][i]) {
      p = dp[p][i];
      q = dp[q][i];
    }
  }
  return Parent[p];
}
long long cnt[300010];
int sums[300010];
void dfsn(int node, int dad) {
  for (int i = 0; i < AdjList[node].size(); i++) {
    int v = AdjList[node][i];
    if (v != dad) {
      dfsn(v, node);
      sums[node] += sums[v];
    }
  }
}
void go(void) {
  for (it = mp.begin(); it != mp.end(); it++) {
    pair<long long, long long> v = it->first;
    int len = mp[v].size();
    int prev = mp[v][0];
    for (int i = 1; i < len; i++) {
      int curr = mp[v][i];
      int l = lca(prev, curr);
      sums[l]++;
      prev = curr;
    }
  }
  dfsn(1, 1);
}
inline void ReadInput(void) {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%lld", &cnt[i]);
  scanf("%s", str);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    AdjList[a].push_back(b);
    AdjList[b].push_back(a);
  }
}
inline void solve(void) {
  dfs(1, 1, pair<long long, long long>(0, 0), 0);
  preprocess();
  go();
  long long ans_val = 0, ans_cnt = 0;
  for (int i = 1; i <= N; i++) {
    long long curr_val = cnt[i] + subtree[i] - sums[i];
    if (curr_val > ans_val) {
      ans_val = curr_val;
      ans_cnt = 1;
    } else if (curr_val == ans_val) {
      ans_cnt++;
    }
  }
  cout << ans_val << endl << ans_cnt << endl;
}
inline void Refresh(void) {}
int main() {
  ReadInput();
  solve();
  return 0;
}
