#include <bits/stdc++.h>
using namespace std;
const int N = 300004;
const long long A = 1610612741;
const long long B = 805306457;
const long long C = 50331653;
int val[N];
string S;
set<pair<long long, long long> > dif[N];
vector<int> adj[N];
pair<int, int> ans;
void dfs(int u, int pa, pair<long long, long long> h) {
  h.first = (h.first * A + S[u - 1]) % B;
  h.second = (h.second * A + S[u - 1]) % C;
  int mx = 0;
  for (auto v : adj[u]) {
    if (v != pa) {
      dfs(v, u, h);
      if (dif[v].size() > dif[mx].size()) mx = v;
    }
  }
  swap(dif[u], dif[mx]);
  for (auto v : adj[u]) {
    if (v != pa && v != mx) {
      for (auto x : dif[v]) {
        dif[u].insert(x);
      }
    }
  }
  dif[u].insert(h);
  if (ans.first < dif[u].size() + val[u]) {
    ans.first = dif[u].size() + val[u];
    ans.second = 1;
  } else if (ans.first == dif[u].size() + val[u]) {
    ans.second++;
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &val[i]);
  }
  cin >> S;
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  ans = {0, 0};
  dfs(1, -1, {0, 0});
  cout << ans.first << '\n' << ans.second;
}
