Sidenote: Is this how friends work? I wouldn't know.
People in a class have friends. If people are friends, friends of friends, friends of friends of friends, and so on, they are in the same friend group. Unfortunately, this class is cursed. By the end of the year, all friendships have broken down. At a given point in time, can you tell whether 2 people are in the same friend group? (Friends are friends of themselves).
Input
The first line contains integers and , the number of people, and the number of queries respectively.
The next lines contains queries of the following forms:
1 a b
indicating that the friendship between and has broken down. Sad.2 a b
asking whether and are currently within the same friendship group.
Output
On each line, output the answer to each query of type 2:
- A
Yes
if they are a part of the same friend group. No
otherwise.
Constrainsts
Example 1
Input
5 10
1 1 2
1 4 5
2 3 4
1 3 4
1 2 5
2 2 5
2 2 5
1 3 5
2 2 4
1 1 5
Output
Yes
No
No
No
Example 2
Input
10 20
2 3 9
2 6 10
1 3 10
2 4 8
1 1 9
1 2 8
2 6 10
2 4 8
1 2 9
1 6 10
1 5 8
1 2 8
1 5 6
2 7 9
1 8 10
2 7 9
2 2 4
1 3 5
1 5 8
2 1 8
Output
Yes
Yes
No
Yes
No
No
No
No
No
Comments