{"problem":{"name":"[EC Final 2022] Rectangle","description":{"content":"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","description_type":"Markdown"},"platform":"Luogu","limit":{"time_limit":8000,"memory_limit":1048576},"difficulty":{"LuoguStyle":"P7"},"is_remote":true,"is_sync":true,"sync_url":null,"sign":"LGP9722"},"statements":[{"statement_type":"Markdown","content":"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.\n\nYou need to choose three straight lines such that:\n\n- Each line should be parallel to the $x$-axis or the $y$-axis, which means its formula is $x = a$ or $y = a$.\n- In the formula $x = a$ or $y = a$, $a$ should be an integer in $[1, 10^9]$.\n- These three lines should be distinct.\n- 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.\n\nYou 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. \n\n## Input\n\nThe first line contains a single integer $T~(1 \\le T \\le 10^5)$, denoting the number of test cases.\n\nFor 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}<x_{i,2}\\le 10^9,1\\le y_{i,1}<y_{i,2}\\le 10^9)$.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $2\\times 10^5$.\n\n## Output\n\nFor each test case, output one integer representing the answer in one line.\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"LGP9722","tags":["线段树","2022","O2优化","ICPC","吉司机线段树 segment tree beats","EC Final"],"sample_group":[["3\n1\n1 1 1000000000 1000000000\n3\n1 1 2 2\n3 3 4 4\n5 5 6 6\n5\n581574116 47617804 999010750 826131769\n223840663 366320907 613364068 926991396\n267630832 51913575 488301124 223957497\n217461197 492085159 999485867 913732845\n28144453 603781668 912516656 993160442","230616300\n64\n977066618"]],"created_at":"2026-03-03 11:09:25"}}