{"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\u003eYou are given a grid $$$g$$$ consisting of $$$n$$$ rows each of which is divided into $$$m$$$ columns. The grid contains unique values between $$$1$$$ and $$$n \\times m$$$ (inclusive).\u003c/p\u003e\u003cp\u003eAlso, you are given two values $$$h$$$ and $$$w$$$, and your task is to find the smallest median value that can be found in a rectangle of size $$$h \\times w$$$.\u003c/p\u003e\u003cp\u003eA rectangle of size $$$h \\times w$$$ is a rectangle consisting of $$$h$$$ rows and $$$w$$$ columns such that its top left corner is at a cell ($$$a,\\,b$$$) and its right bottom corner is at a cell ($$$c,\\,d$$$), and the following conditions are satisfied: ($$$c - a + 1 \\equiv h$$$) and ($$$d - b + 1 \\equiv w$$$).\u003c/p\u003e\u003cp\u003eThe median of a set of numbers is the middle element in the sorted list of the given set. For example, the median of $$$\\{2, 1, 3\\}$$$ is $$$2$$$ and the median of $$$\\{4, 2, 3, 1, 5\\}$$$ is $$$3$$$.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains four integers $$$n$$$, $$$m$$$, $$$h$$$, and $$$w$$$ ($$$1 \\le n,\\,m \\le 10^3$$$, $$$1 \\le h,\\,w \\le n$$$), in which $$$n$$$ and $$$m$$$ are the number of rows and columns in the grid, respectively, and $$$h$$$ and $$$w$$$ are representing the size of the required rectangle. Both $$$h$$$ and $$$w$$$ are odd integers.\u003c/p\u003e\u003cp\u003eThen $$$n$$$ lines follow, each line contains $$$n$$$ integers, giving the grid. It is guaranteed that the grid contains unique values between $$$1$$$ and $$$n \\times m$$$ (inclusive).\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint a single line containing the smallest median value that can be found in a rectangle of size $$$h \\times w$$$.\u003c/p\u003e"}},{"title":"Examples","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 4 3 3\n13 16 15 4\n5 2 8 9\n14 11 12 10\n1 6 3 7\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e6\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, there are $$$4$$$ possible rectangles of size $$$3 \\times 3$$$, which are: \u003c/p\u003e\u003col\u003e \u003cli\u003e Starts at ($$$1,\\,1$$$). $$$\\rightarrow$$$ Contains elements: $$$\\{13, 16, 15, 5, 2, 8, 14, 11, 12\\}$$$. $$$\\rightarrow$$$ Median value \u003d $$$12$$$. \u003c/li\u003e\u003cli\u003e Starts at ($$$1,\\,2$$$). $$$\\rightarrow$$$ Contains elements: $$$\\{16, 15, 4, 2, 8, 9, 11, 12, 10\\}$$$. $$$\\rightarrow$$$ Median value \u003d $$$10$$$. \u003c/li\u003e\u003cli\u003e Starts at ($$$2,\\,1$$$). $$$\\rightarrow$$$ Contains elements: $$$\\{5, 2, 8, 14, 11, 12, 1, 6, 3\\}$$$. $$$\\rightarrow$$$ Median value \u003d $$$6$$$. \u003c/li\u003e\u003cli\u003e Starts at ($$$2,\\,2$$$). $$$\\rightarrow$$$ Contains elements: $$$\\{2, 8, 9, 11, 12, 10, 6, 3, 7\\}$$$. $$$\\rightarrow$$$ Median value \u003d $$$8$$$. \u003c/li\u003e\u003c/ol\u003e\u003cp\u003eSo, the smallest median value that can be found in a rectangle of size $$$3 \\times 3$$$ is $$$6$$$.\u003c/p\u003e"}}]}