168. Matrix

time limit per test: 0.5 sec / memory limit per test: 16000 KB

You are given N*M matrix A. You are to find such matrix B, that B[i,j]=min{ A[x,y] : (y>=j) and (x>=i+j-y) }

Input

On the first line of the input there are two integer numbers, N and M (1<=N,M<=1000). Then matrix A follows: next N lines contains M integers each (not greater than 32000 by absolute value). The j-th number on then i-th of this lines is A[i,j].

Output

Write matrix B in the same format as matrix A, but without N and M.

Example(s)

Sample Input Sample Output
3 3
1 2 3
4 5 6
7 8 9
1 2 3
2 3 6
3 6 9