You are given a tree T with n vertices (numbered 1 through n) and a letter in each vertex. The tree is rooted at vertex 1.

Let's look at the subtree Tv of some vertex v. It is possible to read a string along each simple path starting at v and ending at some vertex in Tv (possibly v itself). Let's denote the number of distinct strings which can be read this way as <image>. 

Also, there's a number cv assigned to each vertex v. We are interested in vertices with the maximum value of <image>.

You should compute two statistics: the maximum value of <image> and the number of vertices v with the maximum <image>.

Input

The first line of the input contains one integer n (1 ≤ n ≤ 300 000) — the number of vertices of the tree.

The second line contains n space-separated integers ci (0 ≤ ci ≤ 109).

The third line contains a string s consisting of n lowercase English letters — the i-th character of this string is the letter in vertex i.

The following n - 1 lines describe the tree T. Each of them contains two space-separated integers u and v (1 ≤ u, v ≤ n) indicating an edge between vertices u and v.

It's guaranteed that the input will describe a tree.

Output

Print two lines. 

On the first line, print <image> over all 1 ≤ i ≤ n. 

On the second line, print the number of vertices v for which <image>.

Examples

Input

10
1 2 7 20 20 30 40 50 50 50
cacabbcddd
1 2
6 8
7 2
6 2
5 4
5 9
3 10
2 5
2 3


Output

51
3


Input

6
0 2 4 1 1 1
raaaba
1 2
2 3
2 4
2 5
3 6


Output

6
2

Note

In the first sample, the tree looks like this:

<image>

The sets of strings that can be read from individual vertices are:

<image>

Finally, the values of <image> are:

<image>

In the second sample, the values of <image> are (5, 4, 2, 1, 1, 1). The distinct strings read in T2 are <image>; note that <image> can be read down to vertices 3 or 4.
import java.io.*;
import java.util.*;

public class D {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;

    List<Integer>[] g;

    static class Node {
        static int lastID = 0;

        Node child, sibling;
        char parSymb;

        int id;

        public Node() {
            id = lastID++;
        }

        public Node(Node sibling, char parSymb) {
            this();
            this.sibling = sibling;
            this.parSymb = parSymb;
        }

        Node go(char c) {
            for (Node to = child; to != null; to = to.sibling) {
                if (to.parSymb == c) {
                    return to;
                }
            }
            Node newNode = new Node(child, c);
            child = newNode;
            return newNode;
        }

    }

    int[] vId;
    char[] s;

    int[] low, high;
    int time = 0;

    int[] order;

    void dfs1(int v, int p, Node trieV) {
        order[time] = v;
        low[v] = time++;
        trieV = trieV.go(s[v]);
        vId[v] = trieV.id;
        for (int to : g[v]) {
            if (to != p) {
                dfs1(to, v, trieV);
            }
        }
        high[v] = time;
    }

    void add(int[] f, int pos, int delta) {
        for (int i = pos; i < f.length; i |= i + 1) {
            f[i] += delta;
        }
    }

    int get(int[] f, int pos) {
        int ret = 0;
        for (int i = pos; i >= 0; i = (i & (i + 1)) - 1) {
            ret += f[i];
        }
        return ret;
    }

    void solve() throws IOException {
        int n = nextInt();
        int[] delta = new int[n];
        for (int i = 0; i < n; i++) {
            delta[i] = nextInt();
        }
        s = nextToken().toCharArray();

        g = new List[n];
        for (int i = 0; i < n; i++) {
            g[i] = new ArrayList<>(2);
        }

        for (int i = 0; i < n - 1; i++) {
            int v1 = nextInt() - 1;
            int v2 = nextInt() - 1;
            g[v1].add(v2);
            g[v2].add(v1);
        }

        vId = new int[n];

        low = new int[n];
        high = new int[n];
        order = new int[n];

        dfs1(0, -1, new Node());

        // System.err.println(Arrays.toString(vId));

        int[] lastOcc = new int[Node.lastID];
        Arrays.fill(lastOcc, -1);

        int[] prevOcc = new int[n]; // from VERTEX NUMBER, not ORDERING

        for (int i = 0; i < n; i++) {
            int v = order[i];
            prevOcc[v] = lastOcc[vId[v]];
            lastOcc[vId[v]] = i;
        }

        Integer[] putQueries = new Integer[n];
        for (int i = 0; i < n; i++) {
            putQueries[i] = i;
        }

        Arrays.sort(putQueries, new Comparator<Integer>() {

            @Override
            public int compare(Integer o1, Integer o2) {
                return Integer.compare(prevOcc[o1], prevOcc[o2]);
            }

        });

        // System.err.println(Arrays.toString(low));
        // System.err.println(Arrays.toString(high));
//      System.err.println(Arrays.toString(order));
//      System.err.println(Arrays.toString(prevOcc));

        int[] diffSub = new int[n]; // from VERTEX NUMBER, not ORDERING

        int[] fen = new int[n];
        for (int i = 0, j = 0; i < n; i++) {
            while (j < n && prevOcc[putQueries[j]] < low[order[i]]) {
                add(fen, low[putQueries[j]], 1);
                j++;
            }
            diffSub[order[i]] = get(fen, high[order[i]] - 1) - get(fen, i - 1);
        }

        int maxSum = -1;
        for (int i = 0; i < n; i++) {
            maxSum = Math.max(maxSum, diffSub[i] + delta[i]);
        }

        int cntMaxSum = 0;
        for (int i = 0; i < n; i++) {
            if (diffSub[i] + delta[i] == maxSum) {
                cntMaxSum++;
            }
        }

        out.println(maxSum);
        out.println(cntMaxSum);
    }

    D() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new D();
    }

    String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }

    String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}