When Omar was at school, his teacher gave him a challenge, and Omar accepted it.
The teacher gave Omar a tree of $$$n$$$ nodes (node $$$1$$$ is the root). The $$$i_{th}$$$ node has a value $$$a_{i}$$$.
Then the teacher asked Omar $$$q$$$ queries of two types:
Omar asks for your help in this challenge.
The first line contains one integer $$$n$$$ $$$(1 \leq n \leq 10^{5})$$$.
The second line contains $$$n$$$ integers $$$(1\leq a_{i} \leq 10^{5})- $$$the value of each node.
For each $$$n-1$$$ lines, it contains two integers $$$u$$$ and $$$v$$$ $$$(1\leq u,v \leq n, u\ne v)-$$$ indices of nodes connected by an edge.
Then the number of queries $$$q$$$ $$$(1\leq q \leq 10^{5})$$$.
Each query format is one of the following:
For each query of the second type, print "$$$YES$$$" without quotes if the sum of all nodes in the subtree with root $$$u$$$ can be represented as the sum of two prime numbers or not, "$$$NO$$$" without quotes otherwise.
93 5 2 7 10 6 1 4 31 22 31 44 55 64 77 87 962 72 21 7 102 71 7 92 7
YES YES YES NO
Name |
---|