{"raw_statement":[{"iden":"problem statement","content":"There is a simple directed graph $G$ with $N$ vertices, numbered $1, 2, \\ldots, N$.\nFor each $i$ and $j$ ($1 \\leq i, j \\leq N$), you are given an integer $a_{i, j}$ that represents whether there is a directed edge from Vertex $i$ to $j$. If $a_{i, j} = 1$, there is a directed edge from Vertex $i$ to $j$; if $a_{i, j} = 0$, there is not.\nFind the number of different directed paths of length $K$ in $G$, modulo $10^9 + 7$. We will also count a path that traverses the same edge multiple times."},{"iden":"constraints","content":"*   All values in input are integers.\n*   $1 \\leq N \\leq 50$\n*   $1 \\leq K \\leq 10^{18}$\n*   $a_{i, j}$ is $0$ or $1$.\n*   $a_{i, i} = 0$"},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$ $K$\n$a_{1, 1}$ $\\ldots$ $a_{1, N}$\n$:$\n$a_{N, 1}$ $\\ldots$ $a_{N, N}$"},{"iden":"sample input 1","content":"4 2\n0 1 0 0\n0 0 1 1\n0 0 0 1\n1 0 0 0"},{"iden":"sample output 1","content":"6\n\n$G$ is drawn in the figure below:\n![image](https://img.atcoder.jp/dp/paths_0_muffet.png)\nThere are six directed paths of length $2$:\n\n*   $1$ → $2$ → $3$\n*   $1$ → $2$ → $4$\n*   $2$ → $3$ → $4$\n*   $2$ → $4$ → $1$\n*   $3$ → $4$ → $1$\n*   $4$ → $1$ → $2$"},{"iden":"sample input 2","content":"3 3\n0 1 0\n1 0 1\n0 0 0"},{"iden":"sample output 2","content":"3\n\n$G$ is drawn in the figure below:\n![image](https://img.atcoder.jp/dp/paths_1_muffet.png)\nThere are three directed paths of length $3$:\n\n*   $1$ → $2$ → $1$ → $2$\n*   $2$ → $1$ → $2$ → $1$\n*   $2$ → $1$ → $2$ → $3$"},{"iden":"sample input 3","content":"6 2\n0 0 0 0 0 0\n0 0 1 0 0 0\n0 0 0 0 0 0\n0 0 0 0 1 0\n0 0 0 0 0 1\n0 0 0 0 0 0"},{"iden":"sample output 3","content":"1\n\n$G$ is drawn in the figure below:\n![image](https://img.atcoder.jp/dp/paths_2_muffet.png)\nThere is one directed path of length $2$:\n\n*   $4$ → $5$ → $6$"},{"iden":"sample input 4","content":"1 1\n0"},{"iden":"sample output 4","content":"0"},{"iden":"sample input 5","content":"10 1000000000000000000\n0 0 1 1 0 0 0 1 1 0\n0 0 0 0 0 1 1 1 0 0\n0 1 0 0 0 1 0 1 0 1\n1 1 1 0 1 1 0 1 1 0\n0 1 1 1 0 1 0 1 1 1\n0 0 0 1 0 0 1 0 1 0\n0 0 0 1 1 0 0 1 0 1\n1 0 0 0 1 0 1 0 0 0\n0 0 0 0 0 1 0 0 0 0\n1 0 1 1 1 0 1 1 1 0"},{"iden":"sample output 5","content":"957538352\n\nBe sure to print the count modulo $10^9 + 7$."}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}