#Lutece1312. Forming Lake

Forming Lake

Migrated from Lutece 1312 Forming Lake

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

There is a mountain standing on a rectangle with lower left corner (0,0)(0,0) and upper right corner (N,M)(N,M).

If it is rainy for a long time, and the surface of mountain can't absorb water, there will be lakes on the mountain finally.

To simplify this problem, the mountain can be described as a NMN*M matrix HH, which Hi,jH_{i,j} is the altitude of the flat square with lower left corner (i1,j1)(i-1,j-1) and upper right corner (i,j)(i,j).

Now you should determine the final depth of water on the square with lower left corner (i1,j1)(i-1,j-1) and upper right corner (i,j)(i,j) for every 1iN1\leq i\leq N and 1jM1\leq j\leq M.

Input

The first line contains two integers NN and MM.

Then NN lines follow, each with MM integers split by spaces, where the jthj^{th} integer in ithi^{th} line indicate Hi,jH_{i,j}.

1N,M10001\leq N, M\leq 1000

1Hi,j1091\leq H_{i,j}\leq 10^9

Output

Print the final depth of water on the square with lower left corner (i1,j1)(i-1,j-1) and upper right corner (i,j)(i,j) for every 1iN1\leq i\leq N and 1jM1\leq j\leq M, using the same format as input.

Samples

4 4
4 4 4 4
4 1 4 4
4 1 1 4
4 4 4 4
0 0 0 0
0 3 0 0
0 3 3 0
0 0 0 0
5 5
2 4 4 4 2
4 2 1 2 4
4 1 2 1 4
4 2 1 2 4
2 4 3 4 2
0 0 0 0 0
0 1 2 1 0
0 2 1 2 0
0 1 2 1 0
0 0 0 0 0

Note

title

A picture for sample 2.

Resources

The 14th UESTC Programming Contest Final