{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e迈克的客厅被$$$m^2$$$个正方形瓷砖覆盖。这些瓷砖形成一个$$$m \\times m$$$网格,其中行从上到下编号为$$$1$$$到$$$m$$$,列从左到右编号为$$$1$$$到$$$m$$$。\u003c/p\u003e\u003ccenter\u003e \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/cb881be9033d55320af586e349017a65?v\u003d1712393455\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \u003c/center\u003e\u003cp\u003e在这些瓷砖上方的地板上铺着$$$n$$$块矩形地毯,其边与网格的边平行。每块地毯覆盖了连续几行和连续几列的交叉部分,形成一个矩形。准确地说,其中第$$$i$$$块地毯由四个整数$$$x_l, x_r, y_l, y_r$$$描述,其中$$$1 \\leq x_l \\leq x_r \\leq m$$$和$$$1 \\leq y_l \\leq y_r \\leq m$$$,表示地毯覆盖了从第$$$x_l$$$行到第$$$x_r$$$行以及从第$$$y_l$$$列到第$$$y_r$$$列的所有瓷砖。\u003c/p\u003e\u003cp\u003e现在迈克要求你移走其中的\u003cspan class\u003d\"tex-font-style-bf\"\u003e正好两块\u003c/span\u003e地毯,以最小化仍然被至少一块剩余地毯覆盖的瓷砖数量。\u003c/p\u003e\u003cp\u003e上面提供的图描述了示例情况,在该图中,具有虚拟边界的两个矩形区域表示了移走两块地毯的最佳方案。\u003c/p\u003e"}},{"title":"输入","value":{"format":"HTML","content":"\u003cp\u003e输入包含多个测试用例,第一行包含一个正整数$$$T$$$,表示测试用例的数量,最多为$$$1000$$$。\u003c/p\u003e\u003cp\u003e对于每个测试用例,第一行包含两个整数$$$n$$$和$$$m$$$,表示地毯的数量和每行或每列的瓷砖数量,其中$$$3 \\leq n \\leq 3 \\times 10^5$$$和$$$1 \\leq m \\leq 1500$$$。\u003c/p\u003e\u003cp\u003e接下来的$$$n$$$行中,每行包含四个整数$$$x_l$$$、$$$x_r$$$、$$$y_l$$$、$$$y_r$$$,描述了地毯在地板上的位置,其中$$$1 \\leq x_l \\leq x_r \\leq m$$$和$$$1 \\leq y_l \\leq y_r \\leq m$$$。\u003c/p\u003e\u003cp\u003e我们保证所有测试用例中$$$n$$$的总和最多为$$$2 \\times 10^6$$$,而所有测试用例中$$$m^2$$$的总和最多为$$$5 \\times 10^7$$$。\u003c/p\u003e"}},{"title":"输出","value":{"format":"HTML","content":"\u003cp\u003e对于每个测试用例,输出一行,包含移走两块地毯后仍然被至少一块剩余地毯覆盖的最小瓷砖数量。\u003c/p\u003e"}},{"title":"示例","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e1\n4 5\n1 1 3 3\n2 2 4 4\n3 3 5 5\n2 3 1 4\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}}]}