{"trustable":false,"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\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003ehyc想在城市里买下一块地来作为acm的训练地\u003c/p\u003e\n\u003cp\u003e城市可以用 $$$n \\times m$$$ 个单元格表示. 每个单元格坐标为 $$$(i, j)$$$ ($$$1 \\le i \\le n$$$; $$$1 \\le j \\le m$$$),并且单元格上都有高度为 $$$a_{i,j}$$$的建筑占据.\u003c/p\u003e\n\u003cp\u003ehyc想要在城市里买一块面积为 $$$l \\times l$$$ 大方格地, 并且该面积范围内的每一个单元小方格上的建筑高度至少为 $$$l$$$.\u003c/p\u003e\n\u003cp\u003e你能帮助hyc找到最大尺寸的 $$$l$$$吗?\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003e每个测试包含多个测试用例。第一行包含测试用例的数量 $$$t$$$ ($$$1 \\leq t \\leq 1000$$$). 测试用例说明如下。\u003c/p\u003e\n\u003cp\u003e每个测试用例的第一行包含两个正整数 $$$n$$$和 $$$m$$$ ($$$1 \\le n \\le m$$$; $$$1 \\leq n \\cdot m \\leq 10^6$$$).\u003c/p\u003e\n\u003cp\u003e接下来$$$n$$$行,第 $$$i$$$行又有 $$$m$$$ 个整数 $$$a_{i,1}, a_{i,2}, \\dots, a_{i,m}$$$ ($$$1 \\leq a_{i,j} \\leq 10^6$$$)\u0026nbsp;— 代表着第 $$$j$$$列.\u003c/p\u003e\n\u003cp\u003e保证所有测试用例中的 $$$n \\cdot m$$$ 之和不超过 $$$10^6$$$.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003e对每个测试用例,打印一个hyc最大能选择的数字 $$$l$$$\u003c/p\u003e"}},{"title":"Sample 1","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\u003e4\n2 2\n2 3\n4 5\n1 3\n1 2 3\n2 3\n4 4 3\n2 1 4\n5 6\n1 9 4 6 5 8\n10 9 5 8 11 6\n24 42 32 8 11 1\n23 1 9 69 13 3\n13 22 60 12 14 17\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\n1\n1\n3\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first test case, we can choose the square of side $$$l \u003d 2$$$ (i.\u0026nbsp;e. the whole grid) since the heights of all buildings are greater than or equal to $$$2$$$.\u003c/p\u003e\n\u003cp\u003eIn the second test case, we can only choose the side as $$$1$$$, so the answer is $$$1$$$.\u003c/p\u003e\n\u003cp\u003eIn the third test case, there are no squares of size $$$2$$$ that have all buildings of height at least $$$2$$$, so the answer is $$$1$$$.\u003c/p\u003e"}}]}