Weights

Time limit: 2s Memory limit: 256MB Input: Output:

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 NN 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 NN teams have the same relative strength, which starts at 11. Then, as the tournament progresses, there will be QQ events, given in chronological order, that are of one of two types:

  • 1 a b1 \ a \ b: Two teams with relative strengths aa and bb play against each other. The winner will have a relative strength equal to a+ba + b 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 aa and at least one team with strength bb (if a=ba = b, then there exist at least two teams with that strength level).
  • 2 k2 \ k: The Krkvan Football Federation wants to compute all pairwise differences in relative strength among the remaining teams and find the kthk^{th} smallest such difference, where kk is between 11 and the total number of such pairs (initially, this number would be at most N(N1)2\frac{N \cdot (N-1)}{2}).

As an example, if the relative strengths of the teams are [4,3,1,1][4, 3, 1, 1], then the pairwise differences are [43,41,41,31,31,11]=[1,3,3,2,2,0][|4-3|, |4-1|, |4-1|, |3-1|, |3-1|, |1-1|] = [1, 3, 3, 2, 2, 0], or [0,1,2,2,3,3][0, 1, 2, 2, 3, 3] when sorted in increasing order. If kk is 44, then the answer is 22.

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 NN and QQ, the number of teams and the number of events.

The next QQ 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 kthk^{th} smallest difference in that respective event.

Constraints and clarifications

  • 1N,Q300 0001 \le N, Q \le 300\ 000
  • For operations of type 2, 1Kx(x1)21 \le K \le \frac{x \cdot (x-1)}{2}, where xx is the number of teams still in the event at the given moment.
# Points Constraints
1 0 Examples
2 9 1N,Q1001 \leq N,Q \leq 100
3 14 1N,Q1 0001 \leq N,Q \leq 1 \ 000
4 12 All events of type 1 take place before all events of type 2 and there will be at most 500500 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 1N,Q50 0001 \leq N,Q \leq 50 \ 000
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

Log in or sign up to be able to send submissions!