P9722 [EC Final 2022] Rectangle
Description
Prof. Pang has $n$ rectangles, the coordinate of the lower left corner of the $i$-th rectangle is $(x_{i,1}, y_{i,1})$, and the coordinate of the upper right corner is $(x_{i,2}, y_{i,2})$. Rectangles may overlap.
You need to choose three straight lines such that:
- Each line should be parallel to the $x$-axis or the $y$-axis, which means its formula is $x = a$ or $y = a$.
- In the formula $x = a$ or $y = a$, $a$ should be an integer in $[1, 10^9]$.
- These three lines should be distinct.
- Each rectangle is $\textbf{touched}$ 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 $998244353$. Two ways are considered the same if only the order of three lines differs in these two ways.
Input Format
The first line contains a single integer $T~(1 \le T \le 10^5)$, denoting the number of test cases.
For each test case, the first line contains an integer $n~(1 \le n \le 10^5)$. The $i$-th line of the next $n$ lines contains four integers $x_{i,1}, y_{i,1},x_{i,2}, y_{i,2}~(1\le x_{i,1}
Output Format
For each test case, output one integer representing the answer in one line.