You are given nodes that are completely separated. You must support the following operations:
1 a bAdd an edge between node and node . . Note that it is not guaranteed node and node are not connected beforehand.
2 a bOutput whether two nodes are connected. Two nodes are connected if there is a path from the first node to the second.
There will be of these operations.
The first line will integers, .
The next lines will each contain a operation as defined above.
For each type operation, print
YES if the two nodes are connected, and
NO otherwise. (Exact capitalization).
Subtask 1 [20%]
Subtask 2 [80%]
No further constraints.
4 5 2 1 3 1 1 2 1 2 4 2 1 4 2 3 4
NO YES NO