You are given matrix *a* of size *n* × *m*, its elements are integers. We will assume that the rows of the matrix are numbered from top to bottom from 1 to *n*, the columns are numbered from left to right from 1 to *m*. We will denote the element on the intersecting of the *i*-th row and the *j*-th column as *a*<sub class="lower-index">*ij*</sub>.

We'll call submatrix *i*<sub class="lower-index">1</sub>, *j*<sub class="lower-index">1</sub>, *i*<sub class="lower-index">2</sub>, *j*<sub class="lower-index">2</sub> (1 ≤ *i*<sub class="lower-index">1</sub> ≤ *i*<sub class="lower-index">2</sub> ≤ *n*; 1 ≤ *j*<sub class="lower-index">1</sub> ≤ *j*<sub class="lower-index">2</sub> ≤ *m*) such elements *a*<sub class="lower-index">*ij*</sub> of the given matrix that *i*<sub class="lower-index">1</sub> ≤ *i* ≤ *i*<sub class="lower-index">2</sub> AND *j*<sub class="lower-index">1</sub> ≤ *j* ≤ *j*<sub class="lower-index">2</sub>. We'll call the area of the submatrix number (*i*<sub class="lower-index">2</sub> - *i*<sub class="lower-index">1</sub> + 1)·(*j*<sub class="lower-index">2</sub> - *j*<sub class="lower-index">1</sub> + 1). We'll call a submatrix inhomogeneous, if all its elements are distinct.

Find the largest (in area) inhomogenous submatrix of the given matrix.
The first line contains two integers *n*, *m* (1 ≤ *n*, *m* ≤ 400) — the number of rows and columns of the matrix, correspondingly.

Each of the next *n* lines contains *m* integers *a*<sub class="lower-index">*ij*</sub> (1 ≤ *a*<sub class="lower-index">*ij*</sub> ≤ 160000) — the elements of the matrix.
import random, time

N = 2
M = 6
#A = [ [random.randrange(0,9), random.randrange(0,9), random.randrange(0,9)] for i in range(3)]
#A = [[5, 2, 3, 1], [3, 3, 5, 3], [4, 4, 4, 5]]
#A = [[1, 2, 3, 4, 5, 6], [8, 6, 7, 8, 9, 1]]
#A = [[1, 3, 1], [4, 5, 6], [2, 6, 1]]
#A = [[3, 5, 2], [4, 4, 4], [0, 2, 4]]
tmp = input()
N, M = tmp.split()
N = int(N)
M = int(M)
print(N,M)
A = []
for i in range(N):
    inputs = list(map(int,input().split()))
    A.append(inputs)

#print("A:", A)
B = dict()
area = 0
greatest_area = 0

for n in range(0,N):
    for m in range(0, M):
        i1, i2 = n+1, n+1
        j1, j2 = m+1, m+1
        B = dict()
        for i in range(n, N):
            for j in range(m, M):
                #print("i: ",i, "j: ", j, "A[i][j]", A[i][j])
                if not A[i][j] in B:
                    B[A[i][j]] = [i,j]
                    i2 = i + 1
                    j2 = j + 1
                else:
                    #print('here')
                    area = 0
                    i = N
                    break
            if i != N:
                area = (i2 - i1 + 1) * (j2 - j1 + 1)
                #print("i1: ", i1, "j1: ", j1, "i2: ", i2, "j2", j2, "area: ", area)
                if area > greatest_area:
                    greatest_area = area

print("area: ", greatest_area)
