PlayerUnknown's Battlegrounds

아직 제출이 없습니다시간 제한1.5초메모리 제한256 MB

문제

When Rikka was playing PUBG (PlayerUnknown's Battlegrounds), she could not win the game. So she decided to use some techniques this time. With the techniques, now Rikka can see clearly where all players are in the game.

In the game, the map can be denoted as a grid of size n×mn \times m. Rikka uses software that can rate the enemy's combat value based on their performance. Now, there is exactly one enemy in each square, and all enemies' combat values form a permutation of integers from 11 to nmn \cdot m. Since Rikka is quite a green hand, she always cares about the weakest enemies (the less the enemy's combat value is, the weaker the enemy is).

We denote the square at row ii, column jj as (i,j)(i,j). A subgrid can be defined by ((x_1,y_1),(x_2,y_2))((x\_1,y\_1), (x\_2,y\_2)), where 1x_1x_2n1 \le x\_1 \le x\_2 \le n and 1y_1y_2m1 \le y\_1 \le y\_2 \le m, and the subgrid itself is the squares (x,y)(x, y) for which x_1xx_2x\_1 \le x \le x\_2 and y_1yy_2y\_1 \le y \le y\_2. Two subgrids ((x_1,y_1),(x_2,y_2))((x\_1,y\_1), (x\_2,y\_2)) and ((x_1,y_1),(x_2,y_2))((x\_1',y\_1'), (x\_2',y\_2')) are the same if and only if ((x_1,y_1),(x_2,y_2))=((x_1,y_1),(x_2,y_2))((x\_1,y\_1),(x\_2,y\_2)) = ((x\_1',y\_1'),(x\_2',y\_2')).

For now, Rikka wants to know how many subgrids are there such that the weakest enemy's combat value in them is equal to xx. Help her find the answers for all x=1,2,,nmx = 1, 2, \ldots, n \cdot m.

입력

The first line of input contains two integers nn and mm (1n,m3001 \le n, m \le 300).

Then follow nn lines. The ii-th of them contains mm integers, where the jj-th integer is the combat value of the enemy in (i,j)(i, j). It is guaranteed that the values form a permutation of integers from 11 to nmn \cdot m.

출력

Print nmn \cdot m lines, with one integer on each line.

The integer on the ii-th line is the answer for x=ix = i.