336. Elections

Time limit per test: 1 second(s)
Memory limit: 262144 kilobytes
input: standard
output: standard



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 .

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.



Input
The first line of the input file contains integers N and M (1 ≤ N ≤ 105; 1 ≤ M ≤ 2 · 105). Next M lines contain pairs of integers a and b denoting that party a knows something discreditable about party b (1 ≤ a, bN). The next line contains single integer number Q (1 ≤ Q ≤ 2 · 105). 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 of the output file answer
YES
or
NO
for each query of the first kind.

Example(s)
sample input
sample output
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
NO
YES
NO




Online Contester Team © 2002 - 2010. All rights reserved.