For each case, the first line contains an integer, n, denoting the number of nodes on the tree. The second line is a binary string, where 1 denotes the male birds and 0 denotes the female birds.
Following by n−1 lines. In each line there are two integers, xi,yi, denoting there is a path connecting node x and node y.
1≤n≤3×105,1≤ xi,yi≤n