You are given a tree with nodes. Each node has a color between and .
For each color from to , print the number of simple paths that contain at least one node with color .
A simple path is a sequence of edges for which all are pairwise distinct. Two paths are considered different if their corresponding sequences of edges are distinct.
Input
Each test contains multiple testcases. The first line of input contains a single integer () — the number of testcases.
The first line of each testcase contains two integers and () — the number of nodes and colors, respectively.
The second line contains integers () — the colors of the nodes.
Each of the next lines contain two integers and (, ), meaning that an undirected edge exists between nodes and .
It is guaranteed that the given graph is a tree (an undirected connected graph without cycles).
It is also guaranteed that the sum of across all testcases does not exceed .
Output
For each testcase, print integers, the number of simple paths that contain at least one node with color , for every color from to .
Example
stdin
4
3 3
1 1 3
1 2
1 3
1 1
1
5 3
1 2 3 2 1
1 2
1 3
3 4
3 5
8 7
1 1 2 3 5 6 7 2
1 2
1 3
1 4
2 5
2 6
3 7
5 8
stdout
8 0 5
1
20 16 19
54 38 15 0 27 15 15
Note
Explanation of the first testcase:
There are simple paths that contain at least one node with color :
Since there are no nodes with color , there are no paths that contain a node with color .
Finally, there are simple paths that contain at least one node with color :
In the second testcase, the only path () contains one node with color .