Michael and Joe are playing a game. The game is played on a grid with $n$ rows and $m$ columns, filled with distinct integers. We denote the square on the $i$-th ($1\le i\le n$) row and $j$-th ($1\le j\le m$) column by $(i, j)$ and the number there by $a_{ij}$.

Michael starts by saying two numbers $h$ ($1\le h \le n$) and $w$ ($1\le w \le m$). Then Joe picks any $h\times w$ subrectangle of the board (without Michael seeing).

Formally, an $h\times w$ subrectangle starts at some square $(a,b)$ where $1 \le a \le n-h+1$ and $1 \le b \le m-w+1$. It contains all squares $(i,j)$ for $a \le i \le a+h-1$ and $b \le j \le b+w-1$.

Possible move by Joe if Michael says $3\times 2$ (with maximum of $15$).

Finally, Michael has to guess the maximum number in the subrectangle. He wins if he gets it right.

Because Michael doesn't like big numbers, he wants the area of the chosen subrectangle (that is, $h \cdot w$), to be as small as possible, while still ensuring that he wins, not depending on Joe's choice. Help Michael out by finding this minimum possible area.

It can be shown that Michael can always choose $h, w$ for which he can ensure that he wins.


-----Input-----

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 20$). Description of the test cases follows.

The first line of each test case contains two integers $n$ and $m$ ($1 \le n, m \le 40$)  — the size of the grid.

Each of the following $n$ lines contains $m$ integers. The $j$-th integer on the $i$-th line is $a_{ij}$ ($-10^9 \le a_{ij} \le 10^9$)  — the element in the cell $(i, j)$.

It is guaranteed that all the numbers are distinct (that is, if $a_{i_1j_1} = a_{i_2j_2}$, then $i_1 = i_2, j_1 = j_2$).


-----Output-----

For each test case print a single positive integer  — the minimum possible area the subrectangle can have while still ensuring that Michael can guarantee the victory.


-----Examples-----

Input
3
1 1
3
4 4
2 12 6 10
3 15 16 4
1 13 8 11
14 7 9 5
2 3
-7 5 2
0 8 -3
Output
1
9
4


-----Note-----

In the first test case, the grid is $1\times 1$, so the only possible choice for $h, w$ is $h = 1, w = 1$, giving an area of $h\cdot w = 1$.

The grid from the second test case is drawn in the statement. It can be shown that with $h = 3, w = 3$ Michael can guarantee the victory and that any choice with $h\cdot w \le 8$ doesn't.

Difficulty: EASY

Solutions:
import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, m) = map(int, sys.stdin.readline().split())
	L = []
	for i in range(n):
		L.append(list(map(int, sys.stdin.readline().split())))
	(i1, j1) = (0, 0)
	for i in range(n):
		for j in range(m):
			if L[i][j] > L[i1][j1]:
				(i1, j1) = (i, j)
	print(max(i1 + 1, n - i1) * max(j1 + 1, m - j1))


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = [list(map(int, input().split())) for _ in range(n)]
	(mn, argmn) = (-10 ** 10, None)
	for i in range(n):
		for j in range(m):
			if a[i][j] > mn:
				mn = a[i][j]
				argmn = (i, j)
	(r, c) = argmn
	lr = max(c, m - c - 1)
	tb = max(r, n - r - 1)
	print((lr + 1) * (tb + 1))


import sys
input = sys.stdin.readline

def solve():
	(n, m) = map(int, input().split())
	arr = [list(map(int, input().split())) for _ in range(n)]
	v = -float('inf')
	point = [0, 0]
	for i in range(n):
		for j in range(m):
			if arr[i][j] > v:
				v = arr[i][j]
				point = [i, j]
	return max(point[0] + 1, n - point[0]) * max(point[1] + 1, m - point[1])
for _ in range(int(input())):
	print(solve())


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	bo = []
	for i in range(n):
		bo.append(list(map(int, input().split())))
	maxi = (-99 ** 99, (-1, -1))
	for i in range(n):
		maxi = max(maxi, (max(bo[i]), (i, bo[i].index(max(bo[i])))))
	(r, c) = maxi[1]
	print(max(r + 1, n - r) * max(c + 1, m - c))


from os import error
import sys
input = sys.stdin.readline
DEBUG = False

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def solve():
	(n, m) = inlt()
	(max_, pi, pj) = (-10 ** 9 - 3, 0, 0)
	for i in range(n):
		row = inlt()
		for j in range(m):
			if max_ < row[j]:
				(max_, pi, pj) = (row[j], i, j)
	pi += 1
	pj += 1
	sq1 = pi * pj
	sq2 = pi * (m - pj + 1)
	sq3 = (n - pi + 1) * pj
	sq4 = (n - pi + 1) * (m - pj + 1)
	return max([sq1, sq2, sq3, sq4])
q = inp()
for t in range(q):
	ans = solve()
	print(ans)


def num():
	c = int(input())
	return c

def stri():
	c = str(input())
	return c

def vector():
	c = list(map(int, input().split()))
	return c

def strvector():
	c = list(map(str, input().split()))
	return c
import math

def isprime(num):
	a = 2
	while a <= math.sqrt(num):
		if num % a < 1:
			return False
		a = a + 1
	return num > 1
t = num()
while t > 0:
	t -= 1
	(n, m) = vector()
	arr = []
	for i in range(n):
		c = vector()
		arr.append(c)
	(x, y) = (0, 0)
	maxi = float('-inf')
	for i in range(n):
		for j in range(m):
			if arr[i][j] > maxi:
				maxi = arr[i][j]
				(x, y) = (i + 1, j + 1)
	a = max(m - y + 1, y)
	b = max(n - x + 1, x)
	print(a * b)


import sys
input = sys.stdin.readline
t = int(input())
out = []
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	arr = []
	max_ = -float('inf')
	coords = []
	for y in range(n):
		arr.append([int(x) for x in input().split()])
		for x in range(m):
			if arr[y][x] > max_:
				max_ = arr[y][x]
				coords = [y, x]
	out.append(str(max(coords[0] + 1, n - coords[0]) * max(coords[1] + 1, m - coords[1])) + '\n')
print(''.join(out))


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = []
	for _ in range(n):
		a.append(list(map(int, input().split())))
	ma = a[0][0]
	(x, y) = (0, 0)
	for i in range(n):
		for j in range(m):
			if a[i][j] > ma:
				ma = a[i][j]
				(x, y) = (i, j)
	print(max(x + 1, n - x) * max(y + 1, m - y))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = []
	for i in range(n):
		b = list(map(int, input().split()))
		a += [b]
	c = []
	for i in range(n):
		c += [max(a[i])]
	x = c.index(max(c))
	y = a[x].index(max(c))
	h = max(x + 1, n - x)
	w = max(y + 1, m - y)
	print(h * w)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = (0, 0)
	maxc = (-10 ** 10, 0, 0)
	for i in range(n):
		x = list(map(int, input().split()))
		for j in range(m):
			if maxc[0] < x[j]:
				maxc = [x[j], i + 1, j + 1]
	h = max(maxc[1], n - maxc[1] + 1)
	w = max(maxc[2], m - maxc[2] + 1)
	print(h * w)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = []
	ma = -1000000002
	for j in range(n):
		a.append(list(map(int, input().split())))
	for j in range(n):
		for k in range(m):
			if a[j][k] > ma:
				ma = a[j][k]
				r = j
				c = k
	h = max(r + 1, n - r)
	w = max(c + 1, m - c)
	print(h * w)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	mm = -1000000001
	(x, y) = (0, 0)
	for i in range(n):
		a = [int(i) for i in input().split()]
		aa = max(enumerate(a), key=lambda x: x[1])
		if aa[1] > mm:
			y = i + 1
			x = aa[0] + 1
			mm = aa[1]
	print(max(x, m + 1 - x) * max(y, n + 1 - y))


t = int(input())
for _ in range(t):
	mx = -10 ** 9 - 1
	mxi = 0
	mxj = 0
	(n, m) = map(int, input().split())
	for i in range(n):
		a = [int(i) for i in input().split()]
		if max(a) > mx:
			mx = max(a)
			mxi = i
			mxj = a.index(max(a))
	l = max(m - 1 - mxj, mxj) + 1
	s = max(n - 1 - mxi, mxi) + 1
	print(s * l)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	z = []
	for i in range(n):
		z.append(list(map(int, input().split())))
	mx = float('-inf')
	for i in range(n):
		for j in range(m):
			if z[i][j] > mx:
				mx = z[i][j]
				ix = i
				iy = j
	x = max(ix + 1, n - ix)
	b = max(iy + 1, m - iy)
	print(x * b)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	max_idx = [0, 0]
	x = None
	for i in range(n):
		itr = list(map(int, input().split()))
		for j in range(m):
			if x == None:
				x = itr[j]
			if itr[j] > x:
				max_idx = [i, j]
				x = itr[j]
	print(max(max_idx[1] + 1, m - max_idx[1]) * max(max_idx[0] + 1, n - max_idx[0]))


def area(A, n, m):
	rw = 0
	cl = 0
	for i in range(n):
		for j in range(m):
			if A[i][j] >= A[rw][cl]:
				rw = i
				cl = j
	rw += 1
	cl += 1
	ans = max(rw * cl, rw * (m - cl + 1), (n - rw + 1) * (m - cl + 1), (n - rw + 1) * cl)
	return ans
tests = int(input())
for _ in range(tests):
	(n, m) = map(int, input().split())
	A = []
	for i in range(n):
		A.append(list(map(int, input().split())))
	print(area(A, n, m))


t = int(input())
for tt in range(t):
	(n, m) = map(int, input().split())
	a = [list(map(int, input().split())) for mm in range(n)]
	m1 = a[0][0]
	k = [0, 0]
	for i in range(n):
		for j in range(m):
			if a[i][j] > m1:
				m1 = a[i][j]
				k = [i, j]
	print(max(k[0] + 1, n - k[0]) * max(k[1] + 1, m - k[1]))


for t in range(int(input())):
	(n, m) = map(int, input().split())
	matrix = []
	for i in range(n):
		matrix.append(list(map(int, input().split())))
	curmax = -10 ** 9
	indx = (0, 0)
	for i in range(n):
		for j in range(m):
			if matrix[i][j] > curmax:
				curmax = matrix[i][j]
				indx = (i, j)
	(i, j) = (indx[0], indx[1])
	print(max(i + 1, n - i) * max(j + 1, m - j))


MAX = 10 ** 9 + 1
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	mat = []
	mx = -MAX
	mxIdx = (0, 0)
	for i in range(n):
		mat.append(list(map(int, input().split())))
		for j in range(m):
			if mat[i][j] > mx:
				mxIdx = (i + 1, j + 1)
				mx = mat[i][j]
	if n == m == 1:
		print(1)
	else:
		r = max(mxIdx[0], n - mxIdx[0] + 1)
		c = max(mxIdx[1], m - mxIdx[1] + 1)
		print(r * c)


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	arr = []
	for i in range(n):
		arr.append(list(map(int, input().split())))
	maxx = -999999999999
	for i in arr:
		for k in i:
			maxx = max(maxx, k)
	(indx, indy) = ([], [])
	for i in range(len(arr)):
		for k in range(len(arr[i])):
			if arr[i][k] == maxx:
				indx.append(i + 1)
				indy.append(k + 1)
	ans = 99999999999
	for i in range(len(indx)):
		ans = min(ans, max(indx[i], n - indx[i] + 1) * max(m - indy[i] + 1, indy[i]))
	print(ans)


t = int(input())
anss = []
for _ in range(t):
	(n, m) = map(int, input().split())
	maxi = 0
	maxi_loc = None
	for i in range(n):
		row = list(map(int, input().split()))
		for j in range(len(row)):
			if maxi_loc is None or row[j] > maxi:
				maxi = row[j]
				maxi_loc = (i, j)
	anss.append(max(maxi_loc[0] + 1, n - maxi_loc[0]) * max(maxi_loc[1] + 1, m - maxi_loc[1]))
[print(ans) for ans in anss]


t = int(input())
while t:
	(n, m) = map(int, input().split())
	matrix = []
	for _ in range(n):
		row = list(map(int, input().split()))
		matrix.append(row)
	cm = []
	M = float('-inf')
	for i in range(n):
		for j in range(m):
			if M < matrix[i][j]:
				cm = [i, j]
				M = matrix[i][j]
	mr = max(cm[0] + 1, n - cm[0])
	mc = max(cm[1] + 1, m - cm[1])
	ans = mr * mc
	print(ans)
	t = t - 1


n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split())
	q = [''] * a
	c = -100000000000.0
	(xx, yy) = (0, 0)
	for i in range(a):
		w = list(map(int, input().split()))
		q[i] = w[:]
		c = max(c, max(w))
		if c == max(w):
			xx = i
			yy = w.index(c)
	dx = max(xx, a - 1 - xx) + 1
	dy = max(yy, b - 1 - yy) + 1
	print(dx * dy)


for q in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	arr = []
	mx = -float('inf')
	for i in range(n):
		temp = [int(x) for x in input().split()]
		arr.append(temp)
		mx = max(mx, max(temp))
	(x, y) = (-1, -1)
	for i in range(n):
		for j in range(m):
			if arr[i][j] == mx:
				(x, y) = (i + 1, j + 1)
				break
	x = max(x, n - x + 1)
	y = max(y, m - y + 1)
	print(x * y)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l = []
	for i in range(a):
		l.append(list(map(int, input().split())))
	maxi = -1000000000.0 - 1
	(x, y) = (0, 0)
	for i in range(a):
		for j in range(b):
			if l[i][j] > maxi:
				maxi = l[i][j]
				(x, y) = (i, j)
	print(max(a - x, x + 1) * max(b - y, y + 1))


import math

def readArr():
	return list(map(int, input().split()))

def readInt():
	return int(input())

def solve():
	(n, m) = readArr()
	maxi = -10 ** 9
	(x, y) = (-1, -1)
	for i in range(n):
		cur = readArr()
		for j in range(m):
			if cur[j] >= maxi:
				(x, y) = (i, j)
				maxi = cur[j]
	print(max(x + 1, n - x) * max(y + 1, m - y))
t = readInt()
for i in range(t):
	solve()


t = int(input())
for TC in range(t):
	(n, m) = map(int, input().split())
	board = []
	for i in range(n):
		board.append([int(x) for x in input().split()])
	mx = (0, 0)
	for r in range(len(board)):
		for c in range(len(board[r])):
			if board[r][c] > board[mx[0]][mx[1]]:
				mx = (r, c)
	print(max(m - mx[1], mx[1] + 1) * max(n - mx[0], mx[0] + 1))


import math
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = []
	maxi = -math.inf
	i1 = 0
	j1 = 0
	for i in range(n):
		l1 = list(map(int, input().split()))
		for j in range(m):
			if l1[j] >= maxi:
				maxi = l1[j]
				i1 = i
				j1 = j
	i1 += 1
	j1 += 1
	newi = max(i1, n - i1 + 1)
	newj = max(j1, m - j1 + 1)
	print(newi * newj)


def solve():
	(n, m) = map(int, input().split())
	mat = []
	for i in range(n):
		mat.append(list(map(int, input().split())))
	maxx = -100000000000
	for i in range(n):
		for j in range(m):
			if maxx < mat[i][j]:
				maxx = mat[i][j]
				maxi = i
				maxj = j
	h = max(maxi + 1, n - maxi)
	w = max(maxj + 1, m - maxj)
	print(h * w)
t = int(input())
for i in range(t):
	solve()


t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	a = []
	for _ in range(n):
		a += [int(x) for x in input().split()]
	idx = a.index(max(a))
	(i, j) = (idx // m, idx % m)
	b = max(j + 1, m - j)
	h = max(i + 1, n - i)
	print(b * h)


import math
t = int(input())
while t:
	t -= 1
	(h, i) = input().split()
	a = int(h)
	b = int(i)
	tab = []
	for i in range(0, a):
		lis = input().split()
		tab.append([int(x) for x in lis])
	ma = max(max(tab, key=max))
	for ind in range(0, a):
		if ma in tab[ind]:
			col = tab[ind].index(ma) + 1
			row = ind + 1
			break
	print(max(row, a - row + 1) * max(col, b - col + 1))


T = int(input())
q = []
for i in range(T):
	x = input().split()
	(a, b) = (int(x[0]), int(x[1]))
	data = []
	for i in range(a):
		temp = [int(i) for i in input().split()]
		data.append(temp)
	q.append((a, b, data))

def solve(a, b, data):
	i_max = 0
	j_max = 0
	maxx = -1000000000.0
	for i in range(a):
		for j in range(b):
			if maxx < data[i][j]:
				maxx = data[i][j]
				i_max = i
				j_max = j
	i_max += 1
	j_max += 1
	if i_max > a / 2:
		h = i_max
	else:
		h = a - i_max + 1
	if j_max > b / 2:
		w = j_max
	else:
		w = b - j_max + 1
	print(w * h)
for (a, b, data) in q:
	solve(a, b, data)


def solve(mat):
	mx = max(map(max, mat))
	(x, y) = (-1, -1)
	for i in range(len(mat)):
		for j in range(len(mat[0])):
			if mat[i][j] == mx:
				x = i
				y = j
	w = max(x + 1, len(mat) - x)
	h = max(y + 1, len(mat[0]) - y)
	return w * h
t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	mat = []
	for i in range(n):
		mat.append(list(map(int, input().split())))
	print(solve(mat))


import math

def solve(n, m, arr):
	if n == 1 and m == 1:
		return 1
	else:
		p = getMax(n, m, arr)
		return max(p[1] + 1, n - p[1]) * max(p[2] + 1, m - p[2])

def getMax(n, m, arr):
	a = -999999999
	(x, y) = (0, 0)
	for i in range(n):
		for j in range(m):
			if arr[i][j] > a:
				a = arr[i][j]
				(x, y) = (i, j)
	return (a, x, y)
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = []
	for i in range(n):
		a = list(map(int, input().split()))
		arr += [a]
	print(solve(n, m, arr))


t = int(input())
for i in range(t):
	a = []
	b = []
	(i1, i2) = (0, 0)
	low = -10 ** 9
	(n, m) = [int(x) for x in input().split()]
	for j in range(n):
		b = list(map(int, input().split()))
		a.append(b)
		for k in range(m):
			if low <= b[k]:
				low = b[k]
				(i1, i2) = (j, k)
		del b
	a1 = max(m - i2, i2 + 1)
	b1 = max(n - i1, i1 + 1)
	print(a1 * b1)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr = []
	for i in range(n):
		l = list(map(int, input().split()))
		arr.append(l)
	(mi, mj) = (0, 0)
	mele = arr[0][0]
	for i in range(n):
		for j in range(m):
			if arr[i][j] > mele:
				mi = i
				mj = j
				mele = arr[i][j]
	mi += 1
	mj += 1
	rmi = n - mi + 1
	rmj = m - mj + 1
	print(max(mi * mj, rmi * rmj, mi * rmj, mj * rmi))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	lst = [list(map(int, input().split())) for x in range(n)]
	(xi, yi) = (0, 0)
	mx = float('-inf')
	for x in range(n):
		for y in range(m):
			if mx < lst[x][y]:
				mx = lst[x][y]
				xi = x
				yi = y
	xi += 1
	yi += 1
	v1 = xi * yi
	v2 = xi * m - xi * (yi - 1)
	v3 = yi * n - (xi - 1) * yi
	v4 = (m - yi + 1) * (n - xi + 1)
	print(max(v1, v2, v3, v4))


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	arr = []
	for i in range(n):
		s = list(map(int, input().split()))
		arr.append(s)
	my_max = arr[0][0]
	my_max_ij = (0, 0)
	for i in range(n):
		if max(arr[i]) > my_max:
			my_max = max(arr[i])
			my_max_ij = (i, arr[i].index(max(arr[i])))
	result = max(n - my_max_ij[0], my_max_ij[0] + 1) * max(m - my_max_ij[1], my_max_ij[1] + 1)
	print(result)


n = int(input())
for i in range(n):
	(ROWS, COLS) = map(int, input().split())
	matrix = []
	for i in range(ROWS):
		matrix.append([int(num) for num in input().split()])
	matrixMax = float('-inf')
	matrixMaxCoord = (0, 0)
	for row in range(ROWS):
		for col in range(COLS):
			if matrix[row][col] > matrixMax:
				matrixMax = matrix[row][col]
				matrixMaxCoord = (row, col)
	(maxRow, maxCol) = (matrixMaxCoord[0], matrixMaxCoord[1])
	maxDistanceX = max(maxRow + 1, ROWS - maxRow)
	maxDistanceY = max(maxCol + 1, COLS - maxCol)
	print(maxDistanceX * maxDistanceY)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	lst = []
	for i in range(n):
		lst1 = list(map(int, input().split()))
		lst.append(lst1)

	def myfunc(mylist):
		x = mylist.index(max(mylist, key=lambda x: max(x)))
		y = mylist[x].index(max(mylist[x]))
		return (x + 1, y + 1)
	(x, y) = myfunc(lst)
	print(max(x, n - x + 1) * max(y, m - y + 1))


def solve():
	(n, m) = map(int, input().split())
	mat = list()
	for i in range(n):
		mat.append(list(map(int, input().split())))
	Max = -2 ** 63
	(row, col) = (-1, -1)
	for i in range(n):
		for j in range(m):
			if mat[i][j] > Max:
				(row, col) = (i, j)
				Max = mat[i][j]
	col += 1
	row += 1
	row = max(row, n - row + 1)
	col = max(col, m - col + 1)
	print(row * col)
for _ in range(int(input())):
	solve()


tests = int(input())
for i in range(tests):
	(rows, cols) = list(map(int, input().split()))
	values = []
	for _ in range(rows):
		values.extend(list(map(int, input().split())))
	max_idx = 0
	for (idx, value) in enumerate(values):
		if values[idx] > values[max_idx]:
			max_idx = idx
	max_idx_coords = [max_idx // cols + 1, max_idx % cols + 1]
	m_rows = [max_idx_coords[0], rows - max_idx_coords[0] + 1]
	m_cols = [max_idx_coords[1], cols - max_idx_coords[1] + 1]
	print(max(m_rows) * max(m_cols))


t = int(input())
for _ in range(t):
	(m, n) = list(map(int, input().split(' ')))
	board = []
	for _ in range(m):
		row = list(map(int, input().split(' ')))
		board.append(row)
	maxVal = None
	rowIdx = None
	colIdx = None
	for i in range(len(board)):
		for j in range(len(board[i])):
			if maxVal is None or board[i][j] > maxVal:
				maxVal = board[i][j]
				rowIdx = i
				colIdx = j
	print(max(colIdx + 1, n - colIdx) * max(rowIdx + 1, m - rowIdx))


t = int(input())
for i in range(t):
	l = [int(i) for i in input().split(' ')]
	n = l[0]
	m = l[1]
	a = []
	max_ = float('-inf')
	maxi = 0
	maxj = 0
	for d in range(n):
		a.append([int(i) for i in input().split(' ')])
		if max(a[d]) > max_:
			max_ = max(a[d])
			maxi = d + 1
			maxj = a[d].index(max(a[d])) + 1
	ans = []
	ans.append(maxi * maxj)
	ans.append(maxi * (m - maxj + 1))
	ans.append((n - maxi + 1) * maxj)
	ans.append((n - maxi + 1) * (m - maxj + 1))
	print(max(ans))


t = int(input())
for i in range(t):
	(n, m) = input().split()
	matrix = []
	for row in range(int(n)):
		temp = list(map(int, input().split()))
		matrix.append(temp)
	max_n = 0
	max_m = 0
	for i in range(len(matrix)):
		for j in range(len(matrix[0])):
			temp = matrix[i][j]
			max_val = matrix[max_n][max_m]
			max_n = max_n if max_val > temp else i
			max_m = max_m if max_val > temp else j
	ans_n = max(int(n) - max_n, max_n + 1)
	ans_m = max(int(m) - max_m, max_m + 1)
	print(ans_n * ans_m)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = [[int(s) for s in input().split()] for i in range(n)]
	imax = 0
	jmax = 0
	for i in range(n):
		for j in range(m):
			if a[i][j] > a[imax][jmax]:
				imax = i
				jmax = j
	print(max(imax + 1, n - imax) * max(jmax + 1, m - jmax))


import sys
input = sys.stdin.readline
print = sys.stdout.write
for _ in range(int(input())):
	(h, w) = map(int, sys.stdin.readline().split())
	check = True
	biggestHeight = 0
	biggestWidth = 0
	for _ in range(h):
		lst = list(map(int, input().split()))
		if check == True:
			check = False
			biggest = lst[0]
		if max(lst) >= biggest:
			biggest = max(lst)
			biggestHeight = _ + 1
			biggestWidth = lst.index(biggest) + 1
	if h - biggestHeight + 1 > biggestHeight:
		biggestHeight = h - biggestHeight + 1
	if w - biggestWidth + 1 > biggestWidth:
		biggestWidth = w - biggestWidth + 1
	print(str(biggestHeight * biggestWidth) + '\n')


p = int(input())
while p:
	(n, m) = map(int, input().split())
	l = []
	for i in range(n):
		a = list(map(int, input().split()))
		l.append(a)
		if i == 0:
			x = max(a)
			y = i
			z = a.index(x)
		elif x < max(a):
			x = max(a)
			y = i
			z = a.index(x)
	h = min(y, n - y - 1)
	w = min(z, m - z - 1)
	(n, m) = (n - h, m - w)
	print(n * m)
	p -= 1


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	tmp = -1000000005
	pos = 0
	ind = 0
	for i in range(1, n + 1):
		lst = list(map(int, input().split()))
		if max(lst) > tmp:
			pos = i
			tmp = max(lst)
			ind = lst.index(tmp) + 1
	print(max(pos, n - pos + 1) * max(ind, m - ind + 1))


import math
t = int(input())
for _ in range(t):
	(n, m) = [int(i) for i in input().split()]
	arr = [[0 for i in range(m)] for j in range(n)]
	for i in range(n):
		arr[i] = list(map(int, input().split()))
	idx = [0, 0]
	mx = -math.inf
	for i in range(n):
		for j in range(m):
			if arr[i][j] > mx:
				mx = arr[i][j]
				idx = [i, j]
	(i, j) = idx
	a = max(j + 1, m - j)
	b = max(i + 1, n - i)
	print(a * b)


import math
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	maxi = -math.inf
	(a, b) = (0, 0)
	for i in range(n):
		temp = list(map(int, input().split()))
		if maxi < max(temp):
			maxi = max(temp)
			a = i
			b = temp.index(maxi)
	print(max(a + 1, n - a) * max(b + 1, m - b))


n_tc = input()
for i in range(int(n_tc)):
	(x, y) = list(map(int, input().split()))
	a = []
	for i in range(x):
		alp = list(map(int, input().split()))
		a.append(alp)
	m = float('-inf')
	for i in range(x):
		for j in range(y):
			if m < a[i][j]:
				m = a[i][j]
				x_ind = i
				y_ind = j
	h = max(x_ind + 1, x - x_ind)
	m = max(y_ind + 1, y - y_ind)
	print(h * m)


def main():
	tee = int(input())
	for _ in range(1, tee + 1):
		(row, col) = list(map(int, input().split()))
		lss = []
		for __ in range(row):
			temp = list(map(int, input().split()))
			lss.append(temp)
		maxi = float('-inf')
		maxa = -1
		maxb = -1
		for a in range(row):
			for b in range(col):
				if maxi <= lss[a][b]:
					maxi = lss[a][b]
					maxa = a + 1
					maxb = b + 1
		print(max(maxa, row - maxa + 1) * max(maxb, col - maxb + 1))
main()


t = int(input())
for i in range(t):
	(n, m) = input().split(' ')
	(n, m) = (int(n), int(m))
	grid = []
	for i in range(n):
		arr = input().split(' ')
		arr = list(map(int, arr))
		grid.append(arr)
	mac = -1000000000.0
	for p in grid:
		if max(p) > mac:
			mac = max(p)
			i = grid.index(p)
	j = grid[i].index(max(grid[i]))
	(h, w) = (max(i + 1, n - i), max(j + 1, m - j))
	print(h * w)


def find_rmax_cmax(grid):
	mx = -10 ** 9 - 1
	(r, c) = (0, 0)
	for (i, row) in enumerate(grid):
		for (j, x) in enumerate(row):
			if x > mx:
				(r, c) = (i, j)
				mx = x
	return (r, c)

def gen_max_sub(n, m, r, c, grid):
	for (nr, nc) in [(r, c), (r, m - 1 - c), (n - 1 - r, c), (n - 1 - r, m - 1 - c)]:
		if (nr + 1) * 2 > n and (nc + 1) * 2 > m:
			return (nr + 1, nc + 1)
	return (0, 0)

def gen_sol(n, m, grid):
	(rmax, cmax) = find_rmax_cmax(grid)
	(r, c) = gen_max_sub(n, m, rmax, cmax, grid)
	return r * c
t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	grid = []
	for _ in range(n):
		line = [int(x) for x in input().split()]
		grid.append(line)
	print(gen_sol(n, m, grid))


import sys

def solve():
	(height, width) = list(map(int, input().split(' ')))
	(max_row, max_col) = (0, 0)
	_max = -sys.maxsize
	for i in range(height):
		row = list(map(int, input().split(' ')))
		for j in range(width):
			if row[j] > _max:
				(max_row, max_col) = (i, j)
				_max = row[j]
	print(max(height - max_row, max_row + 1) * max(width - max_col, max_col + 1))
num_inputs = int(input())
for ____ in range(num_inputs):
	solve()


import sys
T = int(input())
for _ in range(T):
	(n, m) = map(int, input().split())
	lst = []
	high = -1 * 10 ** 9 - 1
	loc = [0, 0]
	for i in range(n):
		inp = input().split()
		tmp = []
		for (j, jj) in enumerate(inp):
			jj = int(jj)
			if jj > high:
				high = jj
				loc = [i, j]
	h = max(loc[0], n - 1 - loc[0]) + 1
	w = max(loc[1], m - 1 - loc[1]) + 1
	print(h * w)


for _ in range(int(input())):
	(n, m) = [int(a) for a in input().split()]
	grid = []
	for i in range(n):
		grid.append([int(b) for b in input().split()])
	best = [grid[0][0], 0, 0]
	for i in range(n):
		for j in range(m):
			if grid[i][j] > best[0]:
				best = [grid[i][j], i, j]
	print(max((best[1] + 1) * (best[2] + 1), (best[1] + 1) * (m - best[2]), (n - best[1]) * (best[2] + 1), (n - best[1]) * (m - best[2])))


t = int(input())
while t > 0:
	t = t - 1
	(n, m) = [int(i) for i in input().split()]
	max_ele = -10 ** 10
	for i in range(n):
		l = [int(ii) for ii in input().split()]
		for j in range(m):
			if l[j] > max_ele:
				max_ele = l[j]
				miny = i
				minx = j
	miny += 1
	minx += 1
	ansx = max([minx, m - minx + 1])
	ansy = max([miny, n - miny + 1])
	print(ansx * ansy)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	mx = -10 ** 9 - 7
	li = []
	for _ in range(n):
		li2 = list(map(int, input().split()))
		mx = max(mx, max(li2))
		li.append(li2)
	for i in range(n):
		for j in range(m):
			if li[i][j] == mx:
				x = max(i + 1, n - i)
				y = max(j + 1, m - j)
				print(x * y)
				break


for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	l = []
	for i in range(n):
		l.append([int(x) for x in input().split()])
	maxi = -10 ** 9
	for i in range(n):
		for j in range(m):
			if maxi <= l[i][j]:
				temp = (i, j)
				maxi = l[i][j]
	print(max(temp[0] + 1, n - temp[0]) * max(temp[1] + 1, m - temp[1]))


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	li = []
	maxi = -10 ** 10
	for i in range(n):
		li.append(list(map(int, input().split())))
		maxi = max(maxi, max(li[-1]))
	(l, r) = (-1, -1)
	for i in range(n):
		for j in range(m):
			if li[i][j] == maxi:
				l = i
				r = j
				break
	print(max(l + 1, n - l) * max(r + 1, m - r))


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	l = []
	fir = 0
	coin = 0
	ind = 0
	for j in range(n):
		lst = list(map(int, input().split()))
		if j == 0:
			fir = max(lst)
			coin = 0
			ind = lst.index(fir)
		elif max(lst) > fir:
			fir = max(lst)
			coin = j
			ind = lst.index(fir)
		l.append(lst)
	row_dist = max(coin + 1, n - coin)
	col_dist = max(ind + 1, q - ind)
	print(row_dist * col_dist)


for _ in range(int(input())):
	a = list(map(int, input().split()))
	l = []
	for i in range(a[0]):
		ad = list(map(int, input().split()))
		l.append(ad)
	m = max(l[0])
	ind = 0
	for i in range(1, a[0]):
		num = max(l[i])
		if num > m:
			m = num
			ind = i
	row = ind + 1
	column = l[ind].index(m) + 1
	ansrow = 0
	anscol = 0
	if row > a[0] / 2:
		ansrow = row
	else:
		ansrow = a[0] - row + 1
	if column > a[1] / 2:
		anscol = column
	else:
		anscol = a[1] - column + 1
	print(anscol * ansrow)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = []
	x = 0
	y = 0
	maxi = -10 ** 10
	for i in range(n):
		ai = list(map(int, input().split()))
		for j in range(m):
			if ai[j] >= maxi:
				y = i
				x = j
				maxi = ai[j]
	print(min(max(x + 1, m - x), m) * min(max(y + 1, n - y), n))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	mat = []
	min = -10 ** 9 - 1
	row = 0
	col = 0
	for _ in range(n):
		mat.append(list(map(int, input().split())))
	for i in range(n):
		for j in range(m):
			if mat[i][j] > min:
				min = mat[i][j]
				row = i
				col = j
	print(max(row + 1, n - row) * max(col + 1, m - col))


import math
for i in range(int(input())):
	(n, m) = map(int, input().split())
	max = -math.inf
	col = 0
	row = 0
	for j in range(n):
		a = list(map(int, input().split()))
		for x in range(m):
			if a[x] > max:
				max = a[x]
				if m - x - 1 > x:
					col = m - x
				else:
					col = x + 1
				if n - j - 1 > j:
					row = n - j
				else:
					row = j + 1
	print(col * row)


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	A = []
	(mx, ii, jj) = (-1000000000000.0, -1, -1)
	for i in range(n):
		B = list(map(int, input().split()))
		for j in range(m):
			if mx < B[j]:
				mx = B[j]
				(ii, jj) = (i, j)
	print(max(ii + 1, n - ii) * max(jj + 1, m - jj))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	mx = -float('inf')
	(l, r) = (-1, -1)
	for i in range(n):
		a = list(map(int, input().split()))
		if max(a) > mx:
			mx = max(a)
			j = a.index(mx)
			(l, r) = (i, j)
	print(max(l + 1, n - l) * max(m - r, r + 1))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	grid = []
	Max = float('-inf')
	for i in range(n):
		grid.append(list(map(int, input().split())))
		a = max(grid[i])
		if a > Max:
			Max = a
			row = i
			col = grid[i].index(a)
	result = 1
	if row == n - 1 or row == 0:
		result *= n
	else:
		result *= max(n - row, row + 1)
	if col == m - 1 or col == 0:
		result *= m
	else:
		result *= max(m - col, col + 1)
	print(result)


for _ in range(int(input())):
	(m, n) = map(int, input().split())
	ans = [float('-inf'), 0, 0]
	for i in range(m):
		a = [*map(int, input().split())]
		for j in range(n):
			if a[j] > ans[0]:
				(ans[0], ans[1], ans[2]) = (a[j], i, j)
	h = max(ans[1] + 1, m - ans[1])
	w = max(ans[2] + 1, n - ans[2])
	print(h * w)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	maxi = -10 ** 9
	x_max_index = 0
	y_max_index = 0
	for i in range(n):
		a = list(map(int, input().split()))
		b = max(a)
		if b > maxi:
			maxi = b
			x_max_index = i + 1
			y_max_index = a.index(max(a)) + 1
	if x_max_index != 0 and x_max_index > n // 2:
		x_max_index = n - x_max_index + 1
	if y_max_index != 0 and y_max_index > m // 2:
		y_max_index = m - y_max_index + 1
	if n == 1 and m == 1:
		print(1)
	else:
		print((n - x_max_index + 1) * (m - y_max_index + 1))


for t in range(int(input())):
	(m, n) = map(int, input().split())
	arr = [[int(x) for x in input().split()] for i in range(m)]
	mx = -float('inf')
	(r, c) = (0, 0)
	for i in range(m):
		for j in range(n):
			if arr[i][j] > mx:
				(r, c) = (i, j)
				mx = arr[i][j]
	row = max(r + 1, m - r)
	col = max(c + 1, n - c)
	print(row * col)


t = int(input())
while t:
	(n, m) = map(int, input().split())
	l = []
	M = -100000000000
	(p, q, a) = (0, 0, 0)
	for i in range(n):
		x = list(map(int, input().split()))
		for j in x:
			a += 1
			if j > M:
				M = j
				q = a
				p = i
		a = 0
		l.append(x)
	q -= 1
	(a, b) = (0, 0)
	p += 1
	q += 1
	if n <= 2:
		a = n
	elif p <= n // 2:
		a = n - p + 1
	else:
		a = p
	if m <= 2:
		b = m
	elif q <= m // 2:
		b = m - q + 1
	else:
		b = q
	print(a * b)
	t -= 1


t = int(input())
for _ in range(t):
	(row, column) = map(int, input().split())
	arr = []
	for _ in range(row):
		num = list(map(int, input().split()))
		arr.append(num)
	maximum = arr[0][0]
	i = 0
	j = 0
	inum = 1
	jnum = 1
	for p in arr:
		for q in p:
			if maximum <= q:
				maximum = q
				i = inum
				j = jnum
			jnum += 1
		inum += 1
		jnum = 1
	standardRow = (row + 1) / 2
	standardCol = (column + 1) / 2
	h = abs(standardRow - i) + standardRow
	w = abs(standardCol - j) + standardCol
	print(int(h * w))


for i in range(int(input())):
	(n, m) = list(map(int, input().split()))
	p = -10 ** 9 - 2
	a = []
	for j in range(n):
		k = list(map(int, input().split()))
		a.append(k)
	for f in range(n):
		for u in range(m):
			if a[f][u] > p:
				p = a[f][u]
				x = f + 1
				y = u + 1
	print(max(x, n + 1 - x) * max(y, m + 1 - y))


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = []
	for i in range(n):
		a.append(list(map(int, input().split())))
	(row, col) = (0, 0)
	for i in range(n):
		for j in range(m):
			if a[i][j] > a[row][col]:
				(row, col) = (i, j)
	(row, col) = (max(row + 1, n - row), max(col + 1, m - col))
	print(row * col)


for _ in [0] * int(input()):
	(n, m) = map(int, input().split())
	a = [[*map(int, input().split())] for _ in [0] * n]
	maxi = [a[0][0], 0, 0]
	for i in range(n):
		for j in range(m):
			if maxi[0] < a[i][j]:
				(maxi[0], maxi[1], maxi[2]) = (a[i][j], i, j)
	print(max(maxi[1] + 1, n - maxi[1]) * max(maxi[2] + 1, m - maxi[2]))


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = [[-1 for i in range(m)] for j in range(n)]
	mx = -10000000000
	for i in range(n):
		a[i] = list(map(int, input().split()))
		mx = max(mx, max(a[i]))
	[x, y] = [-1, -1]
	for i in range(n):
		for j in range(m):
			if a[i][j] == mx:
				x = i
				y = j
	res = max(n - x, x + 1) * max(m - y, y + 1)
	print(res)


x = int(input())
for i in range(x):
	A = input().split()
	n = int(A[0])
	m = int(A[1])
	C = [0] * m
	B = C * n
	maxm = 0
	maxn = 0
	p = 0
	k = 0
	for j in range(n):
		B[j] = input().split()
	maxi = int(B[0][0])
	for a in range(m):
		for b in range(n):
			if int(B[b][a]) > maxi:
				maxi = int(B[b][a])
				maxm = a
				maxn = b
	p = max(maxm + 1, m - maxm)
	k = max(maxn + 1, n - maxn)
	print(p * k)


for _ in range(int(input())):
	(h, w) = [int(i) for i in input().split()]
	m = [int(i) for j in range(h) for i in input().split()]
	a = m.index(max(m))
	(r, c) = (a // w, a % w)
	print(max((h - r) * (c + 1), (c + 1) * (r + 1), (r + 1) * (w - c), (h - r) * (w - c)))


def solve():
	(n, m) = map(int, input().split())
	a = []
	for _ in range(n):
		a.append(list(map(int, input().split())))
	mx = -2 ** 31
	for i in range(n):
		for j in range(m):
			if mx < a[i][j]:
				mx = a[i][j]
				(x, y) = (i, j)
	print(max(x + 1, n - x) * max(y + 1, m - y))
for _ in range(int(input())):
	solve()


num_of_case = int(input())
for _ in range(num_of_case):
	(row, col) = [int(x) for x in input().split(' ')]
	max_pos = (-1, -1)
	max_num = float('-inf')
	for row_idx in range(row):
		r = [int(x) for x in input().split(' ')]
		for col_idx in range(col):
			if r[col_idx] > max_num:
				max_num = r[col_idx]
				max_pos = (row_idx, col_idx)
	if max_pos[0] >= row // 2:
		if max_pos[1] >= col // 2:
			print((max_pos[0] + 1) * (max_pos[1] + 1))
		else:
			print((max_pos[0] + 1) * (col - max_pos[1]))
	elif max_pos[1] >= col // 2:
		print((row - max_pos[0]) * (max_pos[1] + 1))
	else:
		print((row - max_pos[0]) * (col - max_pos[1]))


count = int(input())
ar = [[] for i in range(count)]
for i in range(count):
	(n, m) = [int(c) for c in input().split()]
	for j in range(n):
		ar[i] += [[int(o) for o in input().split()]]
for i in range(count):
	m = max([max(j) for j in ar[i]])
	for j in range(len(ar[i])):
		if m in ar[i][j]:
			indexOfMax = (j, ar[i][j].index(m))
	print(max(len(ar[i]) - indexOfMax[0], indexOfMax[0] + 1) * max(len(ar[i][0]) - indexOfMax[1], indexOfMax[1] + 1))


t = int(input())
while t > 0:
	n = [int(i) for i in input().split()]
	m = n[1]
	n = n[0]
	mi = 0
	mj = 0
	mx = -99999999999
	for i in range(1, n + 1):
		l = [0] + [int(j) for j in input().split()]
		for j in range(1, m + 1):
			if l[j] > mx:
				mx = l[j]
				mi = i
				mj = j
	print(max(m - mj + 1, mj) * max(n - mi + 1, mi))
	t -= 1


t = int(input())
for i_ in range(t):
	sizes = list(map(int, input().split()))
	high = sizes[0]
	width = sizes[1]
	matrix = []
	top_number = -10 ** 9
	coord_top_number = 1
	for j_ in range(high):
		line = list(map(int, input().split()))
		matrix.extend(line)
	for o_ in range(len(matrix)):
		if top_number < matrix[o_]:
			top_number = matrix[o_]
			coord_top_number = o_ + 1
	if coord_top_number % width > 0:
		coord_high = coord_top_number // width + 1
	else:
		coord_high = coord_top_number // width
	if coord_top_number % width > 0:
		coord_width = coord_top_number % width
	else:
		coord_width = width
	if coord_high > high / 2:
		high_kef = coord_high
	else:
		high_kef = high - coord_high + 1
	if coord_width > width / 2:
		width_kef = coord_width
	else:
		width_kef = width - coord_width + 1
	print(width_kef * high_kef)


import math
import sys
import threading
input = sys.stdin.readline
from collections import defaultdict as dd
from collections import deque

def helper(nd):
	vis[nd] = 1
	here = 1
	for ng in gr[nd]:
		if vis[ng] == 0:
			here += helper(ng)
	tot[nd] = here
	return here

def helper1(nd, par):
	ch = []
	for ng in gr[nd]:
		if ng != par:
			ch.append(ng)
	if len(ch) == 0:
		return 0
	if len(ch) == 1:
		return tot[nd] - 2
	return max(tot[ch[1]] - 1 + helper1(ch[0], nd), tot[ch[0]] - 1 + helper1(ch[1], nd))

def shouvik():
	T = int(input())
	for _ in range(T):
		(n, m) = map(int, input().split())
		mat = []
		for _ in range(n):
			mat.append(list(map(int, input().split())))
		mx = -sys.maxsize
		(x, y) = (-1, -1)
		for i in range(n):
			for j in range(m):
				if mat[i][j] > mx:
					mx = mat[i][j]
					(x, y) = (i, j)
		w = max(y + 1, m - y)
		h = max(x + 1, n - x)
		print(w * h)
shouvik()


import sys

def main(a, n, m):
	max_ = float('-inf')
	res = None
	for i in range(n):
		for j in range(m):
			if max_ < a[i][j]:
				max_ = a[i][j]
				res = (i, j)
	nm = [n, m]
	res = [max(nm[i] - res[i], res[i] + 1) for i in range(2)]
	mul = 1
	for i in res:
		mul *= i
	return mul
res = []
num = int(sys.stdin.readline())
for i in range(num):
	(n, m) = [int(i) for i in sys.stdin.readline().split(' ')]
	a = []
	for i in range(n):
		a.append([int(i) for i in sys.stdin.readline().split(' ')])
	res.append(main(a, n, m))
print(*res, sep='\n')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(i) for _ in range(n) for i in input().split()]
	max_a = a.index(max(a))
	(i_max, j_max) = (max_a // m, max_a % m)
	h = max(n - i_max, i_max + 1)
	l = max(m - j_max, j_max + 1)
	print(l * h)


t = int(input(''))
for z in range(t):
	(n, m) = map(int, input().split())
	ma = -10000000000
	for i in range(n):
		a = list(map(int, input('').split()))[:m]
		if max(a) > ma:
			ma = max(a)
			p = i + 1
			q = a.index(max(a)) + 1
	b = n // 2 + 1
	c = m // 2 + 1
	if p < b:
		p = n - p + 1
	if q < c:
		q = m - q + 1
	print(p * q)


T = int(input())
for test in range(T):
	(n, m) = [int(a) for a in input().split()]
	max_val = float('-inf')
	index_r = 0
	index_c = 0
	for i in range(n):
		a = list(map(int, input().split()))
		max_i = max(a)
		if max_i > max_val:
			index_c = a.index(max_i) + 1
			index_r = i + 1
			max_val = max_i
	print(max(index_r, n - index_r + 1) * max(index_c, m - index_c + 1))


def main():
	(n, m) = map(int, input().split())
	ma = -10 ** 9 - 1
	for i in range(n):
		a = list(map(int, input().split()))
		v = max(a)
		if v > ma:
			ma = v
			mi = i
			mj = a.index(v)
	print(max(mi + 1, n - mi) * max(mj + 1, m - mj))
for _ in range(int(input())):
	main()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = []
	for i in range(n):
		k = list(map(int, input().split()))
		l.append(k)
	mx = -10 ** 9 - 2
	x = 0
	y = 0
	for r in range(n):
		for c in range(m):
			if mx < l[r][c]:
				mx = l[r][c]
				x = r
				y = c
	print(max(n - x, x + 1) * max(m - y, y + 1))


t = int(input())
while t:
	t -= 1
	(n, m) = [int(x) for x in input().split()]
	arr = [[] for _ in range(n)]
	for i in range(n):
		arr[i] = [int(x) for x in input().split()]
	tmp = -float('inf')
	index = (0, 0)
	for i in range(n):
		for j in range(m):
			if arr[i][j] > tmp:
				tmp = arr[i][j]
				index = (i, j)
	x = max(index[0] + 1, n - index[0])
	y = max(index[1] + 1, m - index[1])
	print(x * y)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = []
	for i in range(n):
		arr.append(list(map(int, input().split())))
	ma = float('-inf')
	for i in range(n):
		for j in range(m):
			if arr[i][j] > ma:
				ma = arr[i][j]
				mi = i + 1
				mj = j + 1
	print(max(mi, n - mi + 1) * max(mj, m - mj + 1))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	mass = [list(map(int, input().split())) for r in range(n)]
	mx = max([j for i in mass for j in i])
	r = [i for i in mass if mx in i][0]
	(a, b) = (mass.index(r) + 1, r.index(mx) + 1)
	print(max(a, n - a + 1) * max(b, m - b + 1))