Disjoint Sets Union#10811

Disjoint Sets Union

2 seconds
128 megabytes
Very easy

Implement disjoint sets union data structure. You have to perform queries of two types:

Input

The first line contains two integers and (1 \leq n, m \leq 5 \cdot 10^5) - the number of elements and the number of queries. Next lines contain queries, one per line.

For a query union the line looks like union u v (1 \leq u, v \leq n).

For a query get the line looks like get u v (1 \leq u, v \leq n).

Output

Print the result of each query get one per line in the respective order: "YES", if the elements belong to the same set, and "NO" otherwise.

Examples

Example 1

Loading
Loading