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

~/algor $ cat problems/matritsa-kopaytirish

Matrix multiplication

Medium 2000 ms 128 MB 50%
Share

A matrix $A$ of size $n \times k$ and a matrix $B$ of size $k \times m$ are given. Compute their product, the matrix $C = A * B$ (of size $n \times m$):

$$C_{i,j} = \sum_{p=1}^{k} A_{i,p} * B_{p,j}$$

Multiplying the matching rows and columns of two matrices

Input

The first line contains $n$, $k$ and $m$. The next $n$ lines contain $k$ numbers each of matrix $A$, followed by $k$ lines with $m$ numbers each of matrix $B$.

Output

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

Note

$1 \le n, k, m \le 100$
$-100 \le A_{i,p}, B_{p,j} \le 100$

Examples

Input #1
2 3 2
1 2 3
4 5 6
7 8
9 10
11 12
Output #1
58 64
139 154
Input #2
1 1 1
-3
4
Output #2
-12

Sign in to submit a solution

Signing up is free and takes a minute.