PROGRAMMING:Icelandic genealogy
Iceland is a sparsely populated country with complex blood relationship between people. In order to avoid unnecessary accidents, their mobile phones are equipped with a software that can check whether there is blood relationship between two people at any time. Now your task is to realize such a function, receive the registration information of blood relationship, and give us whether two people have blood relationship when we query.
Consanguinity has * * reflexivity * * and * * transitivity * *.
###Input format:
One line of integer $$n $, the following $$n $$lines, each line has three positive integers $$q $, $$a $, $$B$$
If $$q $$is 1, then $$a $$and $$B $$are related by blood
If $$q $$is 2, query the blood relationship between $$a $$and $$B $$, if any, output a line of yes; If not, output a line of No.
###Output format:
For each $$q = 2 $$, output a line of yes or no.
###Input example:
```in
five
1 1 2
1 3 4
2 1 3
1 2 3
2 1 4
```
###Output example:
```out
NO
YES
```
###Data range:
For 20% of the data, $$n < = 1000$$
For 100% data, $$n < = 10 ^ 7 $$, $$1 < = a, B < = n $$< br > < br > < br > < br > < br > for 100% data
answer:If there is no answer, please comment
Consanguinity has * * reflexivity * * and * * transitivity * *.
###Input format:
One line of integer $$n $, the following $$n $$lines, each line has three positive integers $$q $, $$a $, $$B$$
If $$q $$is 1, then $$a $$and $$B $$are related by blood
If $$q $$is 2, query the blood relationship between $$a $$and $$B $$, if any, output a line of yes; If not, output a line of No.
###Output format:
For each $$q = 2 $$, output a line of yes or no.
###Input example:
```in
five
1 1 2
1 3 4
2 1 3
1 2 3
2 1 4
```
###Output example:
```out
NO
YES
```
###Data range:
For 20% of the data, $$n < = 1000$$
For 100% data, $$n < = 10 ^ 7 $$, $$1 < = a, B < = n $$< br > < br > < br > < br > < br > for 100% data
answer:If there is no answer, please comment