t=2
for in range(t):
    int(input(n,m))
M[i][j]
sumi=0
sumj=0
for i in range(1,n+1):
    sumi+=1
for j in range(1,m+1):
    sumj+=1
If sumi/i==0 and sumj/j==0:
       print(M[i][j])
else:
    print("-1")