{"raw_statement":[{"iden":"statement","content":"Givena $n×n$ matrix $A$ and apositive integer $k$，find the sum $S=A+A^2 +A^3 +...+A^k$."},{"iden":"input","content":"The input contains exactly one test case. The first line of input contains three positive integers $n$ ($n \\le 30$), $k$ ($k \\le 10^9$) and $m$ ($m < 10^4$). Then follow n lines each containing $n$ non negative integers below 32,768, giving $A$’s elements in row-major order."},{"iden":"output","content":"Output the elements of $S$ modulo $m$ in the same way as $A$ is given."}],"translated_statement":null,"sample_group":[["2 2 4 \n0 1 \n1 1","1 2\n2 3"]],"show_order":[],"formal_statement":null,"simple_statement":null,"has_page_source":false}