#P9722. [EC Final 2022] Rectangle
[EC Final 2022] Rectangle
题目描述
Prof. Pang has rectangles, the coordinate of the lower left corner of the -th rectangle is , and the coordinate of the upper right corner is . Rectangles may overlap.
You need to choose three straight lines such that:
- Each line should be parallel to the -axis or the -axis, which means its formula is or .
- In the formula or , should be an integer in .
- These three lines should be distinct.
- Each rectangle is by at least one line. A line touches a rectangle if it intersects with the boundary and/or the interior of the rectangle.
You need to compute the number of ways to choose three lines. Since the answer can be very large, output it modulo . Two ways are considered the same if only the order of three lines differs in these two ways.
输入格式
The first line contains a single integer , denoting the number of test cases.
For each test case, the first line contains an integer . The -th line of the next lines contains four integers $x_{i,1}, y_{i,1},x_{i,2}, y_{i,2}~(1\le x_{i,1}<x_{i,2}\le 10^9,1\le y_{i,1}<y_{i,2}\le 10^9)$.
It is guaranteed that the sum of over all test cases does not exceed .
输出格式
For each test case, output one integer representing the answer in one line.
3
1
1 1 1000000000 1000000000
3
1 1 2 2
3 3 4 4
5 5 6 6
5
581574116 47617804 999010750 826131769
223840663 366320907 613364068 926991396
267630832 51913575 488301124 223957497
217461197 492085159 999485867 913732845
28144453 603781668 912516656 993160442
230616300
64
977066618