#C3628. Matrix Addition

    ID: 47076 Type: Default 1000ms 256MiB

Matrix Addition

Matrix Addition

You are given two matrices A and B of dimensions n x m. Your task is to compute their element-wise sum. In other words, you need to compute the matrix C such that \( C_{ij} = A_{ij} + B_{ij} \) for all valid indices.

The matrices are provided in row-major order. Read them from the standard input and output the resulting matrix to the standard output. Each row of the output matrix should be printed on a separate line with the elements separated by a single space.

inputFormat

The input consists of:

  • The first line contains two integers n and m, representing the number of rows and columns respectively.
  • The next n lines each contain m integers representing the matrix A.
  • The following n lines each contain m integers representing the matrix B.

outputFormat

Output the sum matrix C (of dimension n x m) where each element is the sum of the corresponding elements from matrices A and B. Each row should be printed on a new line with elements separated by a space.

## sample
3 3
1 2 3
4 5 6
7 8 9
9 8 7
6 5 4
3 2 1
10 10 10

10 10 10 10 10 10

</p>