Matrix Power Series#1485

Matrix Power Series

1 second
128 megabytes
Easy

Given an n \times n matrix and a positive integer , find the sum S = A + A^2 + A^3 + \ldots + A^k.

Input

The first line contains three positive integers (n \leq 30), (k \leq 10^9), and (m < 10^4). Then follow lines, each containing non-negative integers less than , which define the elements of matrix in row-major order.

Output

Print the elements of matrix modulo in the same format as matrix is given.

Examples

Example 1

Loading
Loading