Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/matritsa-ikki-matritsa-yigindisi

Sum of two matrices

Easy 1000 ms 128 MB 32%
Share

Two integer matrices $A$ and $B$ of the same size $n \times m$ are given. Find their sum, the matrix $C$:

$$C_{i,j} = A_{i,j} + B_{i,j}$$

Adding two matrices of the same size element by element

Input

The first line contains $n$ and $m$. The next $n$ lines contain the elements of matrix $A$, followed by $n$ more lines with the elements of matrix $B$.

Output

$n$ lines with $m$ space-separated integers each.

Note

$1 \le n, m \le 200$
$-1000 \le A_{i,j}, B_{i,j} \le 1000$

Examples

Input #1
2 3
1 2 3
4 5 6
6 5 4
3 2 1
Output #1
7 7 7
7 7 7
Input #2
1 1
5
-5
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.