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.util.*;
import java.io.*;

public class D {
	FastScanner in;
	PrintWriter out;

	int n;
	int[] c;
	char[] let;
	ArrayList<Integer>[] g;
	
	int countLetters = 26;
	
	class Node {
		int v;
		Node[] to;
		int cnt;
		
		Node(int v) {
			this.v = v;
			to = new Node[countLetters];
			cnt = 1;
		}
		
		void set(int i, Node node) {
			to[i] = node;
			cnt += node.cnt;
		}
	}
	
	int ans = 0;
	int ansCnt = 0;
	
	void update(Node node) {
		node.cnt = 1;
		for (int i = 0; i < countLetters; i++) {
			if (node.to[i] != null) {
				node.cnt += node.to[i].cnt;
			}
		}
	}
	
	void add(Node hNode, Node tNode) {
		if (hNode.to[let[tNode.v]] == null) {
			hNode.set(let[tNode.v], new Node(tNode.v));
		}
		Node hNodeTo = hNode.to[let[tNode.v]];
		for (int i = 0; i < countLetters; i++) {
			if (tNode.to[i] != null) {
				add(hNodeTo, tNode.to[i]);
			}
		}
		update(hNode);
	}
	
	Node dfs(int v, int p) {
		Node heavy = null;
		ArrayList<Node> nodes = new ArrayList<>();
		for (int u : g[v]) {
			if (u != p) {
				Node node = dfs(u, v);
				nodes.add(node);
				if (heavy == null || node.cnt > heavy.cnt) {
					heavy = node;
				}
			}
		}
		Node root = new Node(v);
		if (heavy != null) {
			root.set(let[heavy.v], heavy);
			for (Node node : nodes) {
				if (node.v != heavy.v) {
					add(root, node);
				}
			}
		}
		if (c[v] + root.cnt > ans) {
			ans = c[v] + root.cnt;
			ansCnt = 1;
		} else if (c[v] + root.cnt == ans) {
			ansCnt++;
		}
		return root;
	}
	
	public void solve() throws IOException {
		n = in.nextInt();
		c = new int[n];
		g = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			c[i] = in.nextInt();
			g[i] = new ArrayList<>();
		}
		let = in.next().toCharArray();
		for (int i = 0; i < let.length; i++) {
			let[i] -= 'a';
		}
		for (int i = 0; i < n - 1; i++) {
			int u = in.nextInt() - 1, v = in.nextInt() - 1;
			g[u].add(v);
			g[v].add(u);
		}
		dfs(0, -1);
		out.println(ans);
		out.println(ansCnt);
	}

	public void run() {
		try {
			in = new FastScanner();
			out = new PrintWriter(System.out);

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] arg) {
		new D().run();
	}
}