Danger at the Marks
Eric and Lucas are both training for the Olympic sailing regatta, but the venue has only one course. Neither of them is willing to compromise or take turns, so they have to practise in the same space. The danger is at the marks (the inflatable buoys sailors must round), where boats bunch up and can collide. Coach Hung wants them to meet as rarely as possible. Eric always launches from the same mark, while Lucas may start at any other mark, and you have been asked how often they should expect to meet in each case.
The course is laid out around n marks, numbered from 1 to n. Wind and currents push sailors between these marks according to fixed patterns.
For every pair of marks i and j, you are given an integer wi,j. At the end of each minute, a sailor currently at mark i moves to mark j with probability 100wi,j. Every row of these values sums to 100.
Eric and Lucas follow these probabilities independently. Eric always starts at mark 1. Lucas may start at any mark s except mark 1.
Whenever both of them occupy the same mark after a minute has passed, they are said to have met.

For every starting mark s of Lucas from 2 to n, determine the expected number of times the two sailors meet during the next k minutes.
Because the answers may be fractional, output them modulo 109+7. If an expected value equals the rational number qp in lowest terms, output p⋅q−1(mod109+7).
Input
The first line contains two integers n and k (2≤n≤100, 1≤k≤1018).
The next n lines each contain n integers. The j-th integer on the i-th of these lines is wi,j (0≤wi,j≤100). For every row i, ∑j=1nwi,j=100.
Output
Output a single line containing n−1 integers. The i-th of these should be the required answer when Lucas starts at mark i+1.
Example 1
2 2
80 20
30 70
20000001
Explanation
The expected value is 5043.
Example 2
4 5
40 10 20 30
0 50 50 0
25 25 25 25
10 20 30 40
21336070 454089224 404025250
Comments0
No comments yet
Be the first to comment.
New comment
Log in to join the discussion.