Disjoint Sets Union 2
Execution time limit is 3 seconds
Runtime memory usage limit is 128 megabytes
Implement disjoint sets union data structure. You have to perform queries of two types:
union u v — unite two sets that contain and , respectively;
get v — find the set to which belongs to, find the minimal and the maximal element of the set, and the total number of elements in it.
Input
The first line contains two integers and — 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 .
For a query get the line looks like get v .
Output
For each operation get you should output the result on a separate line in the respected order. Each result should consist of three integers: the minimal element, the maximal element, and the number of elements in the set.
Examples
Input #1
Answer #1
Submissions 289
Acceptance rate 54%