All problems

Matrix Addition

mediumPythonMatrices

Brackenhill Garden Centre logs footfall as a grid: one row per day, one column per hour the shop is open. The morning staff and the afternoon staff each keep their own sheet, in the same shape, and the manager wants a single combined grid before the weekly meeting -- one figure per day and hour, covering the whole day. The two sheets arrive back to back, morning first, and the shape is declared once at the top because both share it.

Task: Print the combined grid, cell by cell.

Input

The first line holds two integers rows and cols separated by a single space, with 1 <= rows <= 100 and 1 <= cols <= 100. The next rows lines hold the first sheet, cols integers per line separated by single spaces. The rows lines after that hold the second sheet in the same shape. Figures may be negative.

Output

rows lines, each holding cols integers separated by single spaces.

Example:

Input:
2 2
1 2
3 4
5 6
7 8

Output:
6 8
10 12

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…