spoj#MXSBMTRX. Largest Increasing Sub-Matrix

Largest Increasing Sub-Matrix

当前没有测试数据。

Mosa loves all sorts of properties of matrices. One day his coach Fegla asked him to draw a matrix with size N × M and insert random numbers in each cell, then he asked him to find the largest increasing sub-matrix.

It's defined as a matrix that each cell in the position (i, j) is greater than the cells in positions:

(i - 1, j), (i, j - 1) and (i - 1, j - 1).

Maximum increasing sub-matrix

Help Mosa to find the size of the largest increasing sub-matrix.

Input

t - the number of test cases, then t test cases follows. [t <= 50]

Each test case contains two integers N and M indicating the matrix dimensions [1 <= N * M <= 105].

Each of the next N lines contains M integers, separated by a space, describing the elements of the matrix.

Element Xi,j of the matrix is the jth integer of the ith line in the input [-109 <= Xi,j <= 109].

Output

For each test case in the input your program must print on single line, containing the solution of the problem.

Example

Input:
2
2 3
2 2 2
2 2 2
3 3
1 2 5
4 6 7
10 8 3

Output: 1
6

</p>