#Q221. 「一本通 6.5 例 1」矩阵 A×B

「一本通 6.5 例 1」矩阵 A×B

Description

Matrix AA has dimensions n×mn\times m, and matrix BB has dimensions m×pm\times p. Your task is to compute the product A×BA\times B.

Definition of matrix multiplication: The product of an n×mn\times m matrix and an m×pm\times p matrix results in an n×pn\times p matrix. Let aika_{ik} be an element of matrix AA, and bkjb_{kj} be an element of matrix BB. Then, the elements of the resulting matrix CC are given by:

cij=k=1maikbkjc_{ij}=\sum_{k=1}^m a_{ik}b_{kj}

Refer to the sample for a concrete example.

Input Format

The first line contains two integers nn and mm;

Next, nn lines follow, each containing mm integers, describing matrix AA;

The following line contains an integer pp;

Next, mm lines follow, each containing pp integers, describing matrix BB.

Output Format

Output the matrix CC, which is the product of matrix AA and matrix BB.

Sample 1

$$\begin{bmatrix} 14=1\times 1+2\times 2+3\times 3&14=1\times 1+2\times 2+3\times 3\\ 10=3\times 1+2\times 2+1\times 3&10=3\times 1+2\times 2+1\times 3 \end{bmatrix} $$
2 3
1 2 3
3 2 1
2
1 1
2 2
3 3

14 14
10 10

Data Range and Hint

For all data, 1n,m,p1001\le n,m,p \le 100, and 10000aij,bij10000-10000\le a_{ij},b_{ij}\le 10000.