11145 - Matrix Multiplication   

Description

Given two matrices A and B of size m x n and n x p, calculate C = A x B.

The matrix multiplication is defined as follows:

         n
Cij =  Σ  Aik x Bkj
       k=1

Input

m n
A11 A12  ... A1n
...
Am1 Am2  ... Amn
n p
B11 B12 ... B1p
...
Bn1 Bn2 ... Bnp

Each entry is a positive integer no more than 20, and 0 < m, n, p < 10.

Output

C11 C12 ... C1p
...
Cm1 Cm2 ... Cmp

Print each entry with "%d " (a number followed by a whitespace)
Note that there is a newline character at the end of the output.

Sample Input  Download

Sample Output  Download

Tags




Discuss