#P1572F. Stations

Stations

No submission language available for this problem.

Description

There are nn cities in a row numbered from 11 to nn.

The cities will be building broadcasting stations. The station in the ii-th city has height hih_i and range wiw_i. It can broadcast information to city jj if the following constraints are met:

  • ijwii \le j \le w_i, and
  • for each kk such that i<kji < k \le j, the following condition holds: hk<hih_k < h_i.
In other words, the station in city ii can broadcast information to city jj if jij \ge i, jj is in the range of ii-th station, and ii is strictly highest on the range from ii to jj (including city jj).

At the beginning, for every city ii, hi=0h_i = 0 and wi=iw_i = i.

Then qq events will take place. During ii-th event one of the following will happen:

  • City cic_i will rebuild its station so that its height will be strictly highest among all stations and wciw_{c_i} will be set to gig_i.
  • Let bjb_j be the number of stations that can broadcast information to city jj. Print the sum of bjb_j over all jj satisfying lijril_i \le j \le r_i.

Your task is to react to all events and print answers to all queries.

The first line contains two integers nn and qq (1n,q21051 \le n, q \le 2\cdot10^5) — number of cities and number of events.

Then qq lines follow. The ii-th line begins with an integer pip_i (pi=1p_i = 1 or pi=2p_i = 2).

If pi=1p_i = 1 a station will be rebuilt. Then two integers cic_i and gig_i (1cigin1 \le c_i \le g_i \le n) follow — the city in which the station is rebuilt and its new broadcasting range.

If pi=2p_i = 2 you are given a query. Then two integers lil_i and rir_i (1lirin1 \le l_i \le r_i \le n) follow — the range of cities in the query.

For each query, print in a single line the sum of bjb_j over the given interval.

Input

The first line contains two integers nn and qq (1n,q21051 \le n, q \le 2\cdot10^5) — number of cities and number of events.

Then qq lines follow. The ii-th line begins with an integer pip_i (pi=1p_i = 1 or pi=2p_i = 2).

If pi=1p_i = 1 a station will be rebuilt. Then two integers cic_i and gig_i (1cigin1 \le c_i \le g_i \le n) follow — the city in which the station is rebuilt and its new broadcasting range.

If pi=2p_i = 2 you are given a query. Then two integers lil_i and rir_i (1lirin1 \le l_i \le r_i \le n) follow — the range of cities in the query.

Output

For each query, print in a single line the sum of bjb_j over the given interval.

Samples

Sample Input 1

1 3
2 1 1
1 1 1
2 1 1

Sample Output 1

1
1

Sample Input 2

5 10
1 3 4
2 3 5
1 1 5
2 1 5
1 4 5
2 2 4
1 2 3
2 1 3
1 5 5
2 2 5

Sample Output 2

4
10
5
4
5

Note

In the first test case, only station 11 reaches city 11 before and after it is rebuilt.

In the second test case, after each rebuild, the array bb looks as follows:

  1. [1,1,1,2,1][1, 1, 1, 2, 1];
  2. [1,2,2,3,2][1, 2, 2, 3, 2];
  3. [1,2,2,1,2][1, 2, 2, 1, 2];
  4. [1,1,2,1,2][1, 1, 2, 1, 2];
  5. [1,1,2,1,1][1, 1, 2, 1, 1].