matrix_power

(256000 kilobytes, 1000 milliseconds)

Submissions: 0 · Accepted: 0

Submit code

Statement

Matrix exponentiation

Work modulo

\[ p=1\,000\,000\,007. \]

Given an (n\times n) matrix (A) and a non-negative integer (k), compute

\[ A^k\pmod p. \]

By convention, (A^0=I), the identity matrix.

Input

The first line contains (n) and (k). The next (n) lines contain (A).

Output

Print (A^k) as (n) rows of (n) integers. Any integer representative of
each residue modulo (p) is accepted.

Constraints