Given an $$$n$$$ by $$$m$$$ rectangle print the maximum $$$mex$$$ over all subrectanges. The $$$mex$$$ of a subrectange is defined by the mex of all elements in the subrectangle. The $$$mex$$$ of a set of elements in the minimum excluded non-negative integer. (For example, the $$$mex$$$ of an array $$$[0,1,3,5]$$$ is $$$2$$$.)
The first line of the input contains a single integer $$$t$$$ ($$$1≤t≤50$$$) — the number of test cases. Then the descriptions of the test cases follow.
The first line of each test case contains 2 integers $$$N$$$ and $$$M$$$ ($$$1 \lt = N, M \lt = 500$$$), the size of the grid. The following $$$N$$$ lines contain $$$M$$$ integers each, the $$$j$$$-th element in the $$$i$$$-th line $$$a_{i,j}$$$ is the number written in the $$$j$$$-th cell of the $$$i$$$-th row $$$(0≤a_{i,j}≤250000)$$$
Print out $$$1$$$ integer, the maximum $$$mex$$$ over all subrectanges.
3 3 3 1 2 0 5 2 3 0 5 6 2 2 1 2 0 3 1 1 1
4 4 0
| Название |
|---|


