问题 J: The Mine of Abyss

内存限制:128 MB 时间限制:10 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:0 通过:0

题目描述

Recently, a huge mine with n crystals under deep ground has been detected in Byteland. The crystals are labeled by 1,2,,n. The weight of each crystal is not confirmed, but a range can be estimated. Specifically, the weight of the i-th crystal is an integer within the range [ai,bi].

You are the analyzer of this mine. You will be given q operations, each operation is one of the following:

  • ''1 k a b'' (1kn1ab1e9): The k-th crystal is re-scanned. The new report shows its weight is an integer within the range [a,b]. The previous range is useless now.
  • ''2 l r'' (1lrn): Assume some (maybe none or maybe all) crystals indexed in [l,r] are unearthed, let's measure their total weight, how many possible total weights may we get?

输入格式

The first line contains a single integer T (1T5), the number of test cases. For each test case:

The first line contains two integers n and q (1n,q50,000), denoting the number of crystals and the number of operations.

In the next n lines, the i-th line contains two integers ai and bi (1ai,bi1e9), denoting the weight range of the i-th crystal.

Each of the next q lines describes an operation in formats described in the statement above.

It is guaranteed that all the values of ai,bi,a,b are chosen uniformly at random from integers in their corresponding ranges. The randomness condition does not apply to the sample test case, but your solution must pass the sample as well.

输出格式

For each query, print a single line containing an integer, denoting the number of possible total weights.

输入样例 复制

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

输出样例 复制

3
5
9
13

分类标签