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 AcyclicOrganicCompounds
{
	public static void main(String[] args) throws Exception
	{
		FastScanner in = new FastScanner(System.in);
		
		int n = in.nextInt();
		
		int[] cs = new int[n];
		for(int x = 0; x < n; x++)
		{
			cs[x] = in.nextInt();
		}
		
		char[] s = in.next().toCharArray();
		
		ArrayList<Integer>[] adj = new ArrayList[n];
		for(int y = 0; y < adj.length; y++)
		{
			adj[y] = new ArrayList<Integer>();
		}
		
		for(int z = 0; z < n - 1; z++)
		{
			int u = in.nextInt() - 1;
			int v = in.nextInt() - 1;
			adj[u].add(v);
			adj[v].add(u);
		}
		
		int[] order = new int[n];
		int index = 0;
		
		ArrayDeque<Integer> queue = new ArrayDeque<Integer>();
		queue.add(0);
		
		int[] parent = new int[n];
		Arrays.fill(parent, -1);
		while(queue.size() > 0)
		{
			int node = queue.remove();
			
			order[index] = node;
			index++;
			
			for(int next : adj[node])
			{
				if(parent[next] == -1 && next != 0)
				{
					parent[next] = node;
					queue.add(next);
				}
			}
		}
		
		Trie[] tries = new Trie[n];
		int result = 0;
		int count = 0;
		for(int a = order.length - 1; a >= 0; a--)
		{
			int node = order[a];
			
			tries[node] = new Trie();
			tries[node].reroot(s[node] - 'a');
			
			for(int next : adj[node])
			{
				if(next != parent[node])
				{
					tries[next].reroot(s[node] - 'a');
					if(tries[next].adj.size() < tries[node].adj.size())
					{
						tries[node].merge(tries[next]);
					}
					else
					{
						tries[next].merge(tries[node]);
						tries[node] = tries[next];
					}
				}
			}
			
			int value = cs[node] + tries[node].adj.size();
			if(value > result)
			{
				result = value;
				count = 1;
			}
			else if(value == result)
			{
				count++;
			}
		}
		
		System.out.println(result);
		System.out.println(count);
	}
	
	static class Trie
	{
		int root;
		int ch;
		ArrayList<int[]> adj;
		
		public Trie()
		{
			adj = new ArrayList<int[]>();
		}
		
		public void reroot(int c)
		{
			int[] array = new int[26];
			Arrays.fill(array, -1);
			if(adj.size() > 0)
			{
				array[ch] = root;
			}
			
			root = adj.size();
			ch = c;
			
			adj.add(array);
		}
		
		public void merge(Trie t)
		{
			merge(t, root, t.root);
		}
		
		public void merge(Trie t, int node, int other)
		{
			for(int i = 0; i < t.adj.get(other).length; i++)
			{
				if(t.adj.get(other)[i] != -1)
				{
					if(adj.get(node)[i] == -1)
					{
						adj.get(node)[i] = adj.size();
						
						int[] array = new int[26];
						Arrays.fill(array, -1);
						adj.add(array);
					}
					
					merge(t, adj.get(node)[i], t.adj.get(other)[i]);
				}
			}
		}
	}
	
	static class FastScanner
	{
		BufferedReader br;
		StringTokenizer st;
		
		public FastScanner(InputStream input)
		{
			br = new BufferedReader(new InputStreamReader(input));
			st = new StringTokenizer("");
		}
		
		public String next() throws IOException
		{
			if(st.hasMoreTokens())
			{
				return st.nextToken();
			}
			else
			{
				st = new StringTokenizer(br.readLine());
				return next();
			}
		}
		
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
		}
	}
}
