Next year is our year!
The village of Krkva eventually decided to organize a football tournament. After aggressive advertisements, online campaigns, and various other promotions, they managed to lure teams ready to fight for what could be their only piece of silverware for years to come.
However, the mayor wants to have an unusual tournament and to make it as exciting as possible, they want to calculate certain indicators to further improve their analysis.
Thus, the organizers initially assumed that the teams have the same relative strength, which starts at . Then, as the tournament progresses, there will be events, given in chronological order, that are of one of two types:
- : Two teams with relative strengths and play against each other. The winner will have a relative strength equal to from now on, while the loser is eliminated from the tournament (thus, one less team remains in the tournament). It is guaranteed that there exists at least one team with strength and at least one team with strength (if , then there exist at least two teams with that strength level).
- : The Krkvan Football Federation wants to compute all pairwise differences in relative strength among the remaining teams and find the smallest such difference, where is between and the total number of such pairs (initially, this number would be at most ).
As an example, if the relative strengths of the teams are , then the pairwise differences are , or when sorted in increasing order. If is , then the answer is .
Task
The tournament is coming soon, so Krkva calls for your help to find these answers, or otherwise, the teams will fail to win any silverware for another year.
Input data
The first line of the input contains and , the number of teams and the number of events.
The next lines contain the description of the events, as mentioned in the statement.
Output data
The output shall contain one line for each event of type 2, representing the smallest difference in that respective event.
Constraints and clarifications
- For operations of type 2, , where is the number of teams still in the event at the given moment.
# | Points | Constraints |
---|---|---|
1 | 0 | Examples |
2 | 9 | |
3 | 14 | |
4 | 12 | All events of type 1 take place before all events of type 2 and there will be at most teams remaining after performing the events of type 1. |
5 | 10 | All events of type 1 take place before all events of type 2. |
6 | 21 | |
7 | 34 | No additional constraints |
Example
stdin
10 15
2 45
1 1 1
1 1 1
1 1 1
2 9
2 10
1 1 2
2 1
2 5
2 13
1 1 1
1 2 2
2 1
2 4
2 6
stdout
0
0
1
0
1
2
1
2
3