#Q117. 「一本通 4.1 例 3」校门外的树

「一本通 4.1 例 3」校门外的树

Description

Original source: Vijos P1448

There are many trees outside the school gate. The school decides to plant a certain type of tree in a specific interval at a certain time, ensuring that no two intervals have the same type of tree at any given moment. There are two types of operations:

  • K=1K=1, read l,rl,r indicating that a tree is planted between ll and rr, with each operation planting a different type of tree;
  • K=2K=2, read l,rl,r indicating a query about how many types of trees exist between ll and rr.

Note: Each position can have trees planted repeatedly.

Input Format

The first line contains n,mn,m, where nn is the total length of the road and mm is the number of operations;
The next mm lines describe the mm operations.

Output Format

For each k=2k=2 operation, output an answer.

Sample 1

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

1
2

Data Range and Hints

For 20%20\% of the data, 1n,m1001\le n,m\le 100;
For 60%60\% of the data, 1n103,1m5×1041\le n\le 10^3,1\le m\le 5\times 10^4;
For 100%100\% of the data, 1n,m5×1041\le n,m\le 5\times 10^4, ensuring l,r>0l,r\gt 0.