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
- \(1\le n\le 100\)
- \(0\le k\le 10^{18}\)
- Every matrix entry is an integer in \([0,p)\)