2400: 矩阵快速幂

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:4 Solved:4

Description

给定一个 n×n的矩阵A,求矩阵Am次幂模p的值

Input

第一行包含整数 n,m,p

接下来 n 行,每行包含n个正整数ai,整数之间以空格相隔

Output

输出计算之后的矩阵

Sample Input Copy

2 7 10
1 2
3 4

Sample Output Copy

3 6
9 2

HINT

数据范围

1≤nmp≤100

Source/Category