No tags yet

No tag edit access

time limit per test: 0.5 sec.

memory limit per test: 16000 KB

memory limit per test: 16000 KB

input: standard

output: standard

output: standard

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) }

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].

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

Input

3 3

1 2 3

4 5 6

7 8 9

1 2 3

4 5 6

7 8 9

Output

1 2 3

2 3 6

3 6 9

2 3 6

3 6 9

Author: | NNSU #2 team |

Resource: | |

Date: |

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: May/24/2019 07:11:05 (e3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|