You are given a tree of nodes, the i-th node has value . Define a node is valid, if you can divide the nodes into two sets and , so that the following condition would hold:
, if is on the path from to , then
, if is on the path from to , then
You need to find out whether the node is valid.
输入描述:
The first line contains one integer . The second line contains integers . The next lines each contains two integers and , denoting an edge between node and .