Disjoint Sets Union 2#10814

Disjoint Sets Union 2

3 seconds
128 megabytes
Medium

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

Input

The first line contains two integers and m~(1 \le n, m \le 3 \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 \le u, v \le n).

For a query get the line looks like get v ~(1 \le v \le n).

Output

For each operation get you should output the result on a separate line in the respective order. Each result should consist of three integers: the minimal element, the maximal element, and the number of elements in the set.

Examples

Example 1

Loading
Loading