Domo is a brilliant dog, he wants to find a perfect size Christmas tree, could you help him?
There's a tree with N nodes; the root is node 1.
The size of node i is the sum of the value of all nodes in the subtree whose root is node i.
Can you find all nodes such that the absolute difference between the size of it and X is smaller than D? (i.e. |Size - X| < D)
Here's an example. The following image describes a tree and the member of node 3's subtree, node 6's subtree, and node 4's.
The sample input is the same as the tree above, you can find further information from it.
Hint: the size of node 1 to node 10 is
[19, 2, 10, 4, 7, 2, 1, 2, 1, 1]
Given three integers N and X and D, which represent the number of nodes in the tree, X and D. (1 ≤ N, X, D ≤ 1000)
The next line consists of N integers (V1, V2, ..., VN), representing the value of nodes. (0 ≤ Vi ≤ 20)
For the following N-1 lines, each line consists of two numbers i and j, representing an edge between node i and node j. (1 ≤ i, j ≤ N)
Output the nodes that the absolute difference of its size and X is smaller than D in ascending order, separating every integer with a space.
Remember to print a newline character at the end of the line.