DSU
Easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
In Uzlandia, there are n cities, numbered from 1 to n. Initially, there are no roads connecting these cities, but roads will be constructed over time.
Tourist Vasyl has asked you to handle q queries of two types:
1 a b - Construct a bidirectional road between cities a and b.
2 a b - Determine if it's possible to travel from city a to city b using the existing roads. Output "YES" if travel is possible, otherwise output "NO".
Input
The first line contains the integers n and q. (1 ≤ n, q ≤ 2 \times 10^5)
The following q lines contain the queries.
Output
Provide the answers for each query of type 2.
Examples
Input #1
Answer #1
Submissions 315
Acceptance rate 21%