eolymp
bolt
Try our new interface for solving problems
Problems

Elections

Elections

New parliament election in Berland is coming soon. Each of n political parties wants to be elected into the parliament. There is a law in Berland that allows only parties with more than a certain amount of votes be elected. Thus, some of the smaller parties are trying to use different technologies to collect necessary amount of votes.

The first technology is completely legal. Two or more parties can go to the elections together, forming so-called election block.

The second technology is not so legal. Some parties have specific information about their opponents. Those opponents don't want this information to become public.

If several parties join into one election block, their information is joined together as well. Thus, they become more powerful. However, the opponents of each party of the block know something discreditable about the whole block. The party or block might have some `black' information on itself.

Let us now enumerate parties with the integers from 1 to n. Parties and blocks are allowed to join together into new blocks. Those blocks are numbered with the consecutive integers (n + 1, n + 2, etc.).

You are to write a program that processes queries of two different kinds.

  • Query 1 a b means that you have to answer the question: is there any discreditable information that party or block a knows about party or block b?

  • Query 2 a b means that you need to join party or block a with party or block b. The new block will have all the information a has, and all the information b has. All the information that was known by some parties or blocks about a and b now concerns the newly created block.

Input

The first line contains integers n and m (1n100 000, 1m200 000). Next m lines contain pairs of integers a and b denoting that party a knows something discreditable about party b (1a, bn). The next line contains single integer number q (1q200 000). Each of the next q lines contains a query. A query of the first kind looks like 1 a b. A query of the second kind looks like 2 a b. You should process queries in the order they are given. Each pair a, b references only existing parties or blocks. It is guaranteed that numbers a and b are different in any 2 a b query, but they can be equal in a 1 a b query.

Output

Write on the separate lines answer YES or NO for each query of the first kind.

Time limit 3 seconds
Memory limit 128 MiB
Input example #1
4 6
1 2
1 3
3 2
4 4
2 4
1 2
4
1 3 4
2 2 3
1 5 4
1 4 5
Output example #1
NO
YES
NO
Source 2007 Петрозаводск, Saratov for Karelia with love, Январь 28, Задача A