404772: GYM101628 I In the clouds
Description
Tiago lives in a street with N houses, numbered from 1 to N, in which the first one is his. He decided to get out of Codeforces and visit a friend, but his head is stuck in a problem for several days. Because of that, he is bit distracted and is not paying attention to where he is going.
The walk can be represented by K steps, where if he is in house i in a step, is the probability of him being at house j in the next step. He wants to know what is the expected value of the house where he'll stop, but he is too distracted to solve this problem.
InputThe first line of input consists of two integers N and K (1 ≤ N ≤ 100, 1 ≤ K ≤ 109). The next N lines contain each N integers, where the j-th number in the i-th line is Aij (0 ≤ Aij ≤ 106) and the sum in each line is 106.
OutputThe answer can be represented as an irreducible fraction . Print the integer P * Q - 1 modulo 109 + 7 (Q - 1 is the modular inverse of Q modulo 109 + 7).
ExamplesInput2 2Output
500000 500000
500000 500000
500000005Input
4 24255Output
283383 274729 386113 55775
167247 49080 415640 368033
449168 182769 352198 15865
127605 304475 230640 337280
96636490Input
2 2Output
0 1000000
1000000 0
1Input
2 1Output
0 1000000
1000000 0
2