Stevie : "The more you play with Christmas Trees, the more addicted you are to them. Let's go on". Legends serve a club selflessly for ages without any noise off the pitch. Do you remember the headed goal vs the Gunners with a highly bandaged head by this guy : ?
You are given a Tree T consisting of N nodes where node i of the tree has number
The answer to the second kind of query is either a YES or NO .
Can you answer all the given queries efficiently?
Input Format :
The first line contains 2 space separated integer N and Q denoting the number of nodes in tree T and the number of queries respectively.
The next line contains N space separated integers, where the
Each of the next
It is guaranteed that the input edges are such that it always forms a valid tree.
Each of the next Q lines contains a query of either of the two types on a single line.
Output Format:
Print the answer to each query of type 2 in the order they appear in the input on a new line. The answer to the queries shall be either a YES or a NO.
Constraints :
Query 1: The path from 1 to 5 is 1->2->3->4->5. The product of numbers written on these nodes is 12345 which is divisible by 120.
Query 2: The path from 1 to 2 is 1->2. The product of numbers written on these nodes is 2*2 which is divisible by 4.
Please login to use the editor
You need to be logged in to access the code editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor