Gym

No attempts yetTime limit1sMemory limit128 MB

Problem

Model a gym-class game as a random process.

An entertaining game elementary-school children play in gym class works as follows.

  • $N$ baskets are placed at various spots on the gym floor, each marked with a distinct picture.
  • Each basket holds several index cards, and every card names a destination basket.

How the game is played: the children gather at a fixed starting basket. In turn, each child draws one card at random from the basket, memorizes the destination, and returns the card before the next child draws. When the teacher blows the whistle, every child moves to the basket written on the card they drew.

Given the card composition of each basket, determine the probability that a child is standing at each basket during the first ten steps of the game.

For example, suppose there are four baskets — "tree", "house", "car", and "park" — with the following cards.

  • "tree" basket: two "tree" cards, one "house" card, two "car" cards
  • "house" basket: one "tree" card, one "car" card, two "park" cards
  • "car" basket: one "tree" card
  • "park" basket: one card of each kind

As a table:

basket \ destinationtreehousecarpark
tree2120
house1012
car1000
park1111

Everyone starts at the first basket (tree), so initially $P_0(\text{tree}) = 1$ and $P_0 = 0$ for every other basket.

At any later step, the probability of being at a new location equals the sum, over every location, of the probability of being there on the previous step times the probability of moving from that location to the new one. In the example,

$$P_{s+1}(\text{tree}) = 0.40,P_s(\text{tree}) + 0.25,P_s(\text{house}) + 1.00,P_s(\text{car}) + 0.25,P_s(\text{park})$$

(for instance, the chance of going tree to tree is $2/5 = 0.40$, and house to tree is $1/4 = 0.25$).

The game always begins at the first basket.

Input

The input is a table of card counts spanning $N$ lines. Line $i$ contains $N$ integers giving the cards in basket $i$ in destination order; the $j$-th value is how many "go to basket $j$" cards are inside basket $i$.

The number of baskets $N$ equals the number of input lines (and the count of integers per line), with $2 \le N \le 10$. Within one basket there are at most 10 cards for any single destination, and every basket holds at least one card (each line sums to at least 1).

Output

Print exactly 10 lines. Line $s$ (for $s = 0, 1, \dots, 9$) lists the probabilities $P_s(1), P_s(2), \dots, P_s(N)$ that the child is at each basket after $s$ steps, separated by single spaces. The first line is the starting distribution, so the first basket is $1.00000$ and the rest are $0.00000$.

Print each probability rounded to exactly five digits after the decimal point (e.g. 1.00000). Performing the internal computations in double-precision arithmetic is recommended.