Salt and Pepper has decided to survey all the restaurants from the city to know which of them are its allies and which of them are its enemies. They have given this task to the bright residents of our G-Wing! Note that any two restaurants can either be allies or rivals or neutral. There are N restaurants in Gandhinagar numbered from 0 to N-1. There are four types of queries which you have to answer for given two restaurants x and y:-
Q = 1 Answer whether restaurant x and y are allies or not by printing YES or NO.
Q = 2 Answer whether restaurant x and y are rivals or not by printing YES or NO.
Q = 3 Make restaurant x and y allies. If they are already enemies print -1 and do nothing.
Q = 4 Make restaurant x and y rivals. If they are already allies print -1 and do nothing.
Ally and Rivalry are both mutual (Eg. if a is ally with b, then b is also ally with a).
Each restaurant is ally of itself and no restaurant is rival of itself.
Assume there are 3 restaurants a, b, c
If a is ally with b and b is ally with c, then a is also ally with c.
If a is ally with b and b is rival with c, then a is also rival with c. (Rival of ally is your rival).
If a is rival with b and b is rival with c, then a is ally with c. (Rival of rival is your ally).
Input :
First line will contain N and T denoting the number of restaurants and number of queries respectively. Each of the next T lines will contain three integers Q q w denoting the query type mentioned above, restaurants q and w respectively.
Output :
Answer the queries as mentioned above.
Constrains :
2 <= N, T <= 1000000
1 <= Q <= 4
0 <= q,w < N
Author : Manish Berwani
First Query makes 1 and 2 allies.
Second Query makes 2 and 5 allies.
Third Query makes 3 and 4 allies.
Fourth Query tries to make 1 and 5 enemy, but they are already friends. So it prints -1.
Fifth Query makes 2 and 6 rivals.
Sixth Query:- 1 and 5 are allies so YES
Seventh Query:- 2 and 3 are not rivals so NO
Eighth Query:- 2 and 6 are rivals and not allies so NO