There are $N$ students. Process $Q$ operations. 0 a b makes $a$ and $b$ friends (merging their groups). 1 a b asks whether $a$ and $b$ are in the same group; print YES or NO.
Input
First line $N$ and $Q$; then $Q$ lines each T a b ($1 \le a, b \le N$, $T \in {0, 1}$).
Output
For every type-$1$ operation print YES or NO on its own line.
Example 1
Input
7 8 0 1 3 1 1 7 0 7 6 1 7 1 0 3 7 0 4 2 0 1 1 1 1 6
Output
NO NO YES
Discussion
Threads about this problem. Spoilers are collapsed; wrap hints in
||double bars||.No discussion yet. Start a thread if something here needs explaining.