#K43542. Generate Door Passcodes

    ID: 27332 Type: Default 1000ms 256MiB

Generate Door Passcodes

Generate Door Passcodes

You are given a number of doors K and the length N of a passcode for each door. The passcodes are generated dynamically.

For each door i (1 ≤ i ≤ K), the first digit of its passcode is i. Then, for each subsequent position j (1 ≤ j ≤ N-1), the digit is obtained by adding an increment from a given list to the previous digit. In particular, if we denote the passcode digits for door i by \(a_0, a_1, \dots, a_{N-1}\) and the list of increments by \(b_0, b_1, \dots, b_{N-2}\), then the following recurrence holds:

\(a_{j} = a_{j-1} + b_{j-1}\) for \(1 \leq j \leq N-1\).

Your task is to generate and output the passcodes for all K doors.

inputFormat

The first line of the input contains two space-separated integers K and N, representing the number of doors and the length of each passcode, respectively.

If N > 1, then the second line contains N-1 space-separated integers representing the increments.

outputFormat

Output exactly K lines. Each line should contain N integers separated by a single space representing the passcode for that door.

## sample
4 5
1 1 -1 2
1 2 3 2 4

2 3 4 3 5 3 4 5 4 6 4 5 6 5 7

</p>