N children want to play a game, so they need to form teams. Each child has strength. The strength of the i′th children is i. Initially, no team is created, and all children are on their own, so there are N teams in the beginning.
You need to perform Q queries to help them in the team forming task. The query can be of 3 types as follow:
For each query of type 2, you need to output two things, the team's size and total strength.
Input Format:
Output Format:
For each test case, output an array that contains the answer for every query of type 2.
Constraints:
1≤T≤10
2≤N≤2∗104
1≤Q≤105
Query type 1 or type 3 (1 A B or 3 A B):
1≤A≤N
1≤B≤N
A!=B
The query of type 2(2 A):
1≤A≤N
For test case 1:
We have 4 children, and we perform queries in the following manner:
First query: 1 1 2
Combine team of 1 and 2 so team configuration will be {1, 2}, {3}, {4}.
Second query: 3 2 3
Move 2 from it’s team to team of 3 so configuration will be {1}, {2,3}, {4}.
Third query: 2 3
A team of 3 contains two elements {2, 3} so the size will be 2, and the strength will be 5.
Hence, the answer will be [2, 5].
For test case 2:
We have 3 children here and 2 queries as follows:
Initial team configuration will be {1}, {2}, {3}.
First query: 2 1
Its output will be 1 1 as size is 1 and strength is also 1.
Second query: 2 2
Its output will be 1 2 as size is 1 and strength is 2.