#M001. [模板题]矩阵乘法

[模板题]矩阵乘法

Problem Description

This is a template problem.

You are given two matrices A A and B B , where A A is of size n×p n \times p and B B is of size p×m p \times m . Your task is to compute the matrix product A×B A \times B .

Input Format

The first line contains three positive integers n n , p p , and m m , representing the dimensions of the matrices.
The next n n lines each contain p p integers, representing matrix A A .
The following p p lines each contain m m integers, representing matrix B B .

Output Format

Output an n n -row by m m -column matrix, representing the result of the matrix multiplication A×B A \times B . Each element of the result should be output modulo 109+7 10^9 + 7 .

Example Input 1

3 4 5
-2 -8 -9 8
-10 0 6 -8
-10 -6 6 9
4 -7 5 -5 9
10 -2 -10 5 5
-3 -7 -3 8 -2
-6 7 7 3 -2

Example Output 1

999999898 149 153 999999929 999999951
999999997 999999979 999999883 74 999999921
999999835 103 55 95 999999857

Constraints and Hints

  • 1n,p,m500 1 \leq n, p, m \leq 500
  • 109Ai,j,Bi,j109 -10^9 \leq A_{i,j}, B_{i,j} \leq 10^9

This problem involves performing matrix multiplication and ensuring that the result is output modulo 109+7 10^9 + 7 .