cswork / OAOpen practice workspace

Arista NetworksOA #1

Generate Matrix B

Estimated EasyJudge-ready

Topics (AI-labelled)Prefix & Ranges

In row-major order, write the prefix sums of the flattened matrix A back into a matrix B of the same size.

This site's standard I/O format and supplementary bounds follow this problem's statement.

Input

The first line contains m n (1≤m,n≤1000, mn≤2×10^5), followed by m lines of n integers each (−10^9≤Aij≤10^9).

Output

Output m lines, each with n prefix sums.

Example 1

Input:

2 3
1 2 3
4 5 6

Output:

1 3 6
10 15 21

Example 2

Input:

1 1
-7

Output:

-7

Example 3

Input:

1 1
-3

Output:

-3

Editorial

Loading solution…