Merging Cells
문제
Bessie is having fun playing a famous online game, where there are a bunch of cells of different labels and sizes. Cells get eaten by other cells until only one winner remains.
There are () cells in a row labeled from left to right, with initial sizes (). While there is more than one cell, a pair of adjacent cells is selected uniformly at random and merged into a single new cell according to the following rule:
If a cell with label and current size is merged with a cell with label and current size , the resulting cell has size and label equal to that of the larger cell, breaking ties by larger label. Formally, the label of the resulting cell is
For each label in the range , the probability that the final cell has label can be expressed in the form where . Output .
입력
The first line contains .
The next line contains .
출력
The probability of the final cell having label modulo for each in on separate lines.
예제
예제 1
3 1 1 1
0 500000004 500000004
예제 2
4 3 1 1 1
666666672 0 166666668 166666668