409536: GYM103625 J Pirate Races

Memory Limit:256 MB Time Limit:8 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. Pirate Racestime limit per test8 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Edward Kenway, the most fearsome pirate-assassin ever to sail the seven seas, has stumbled upon a massive amount of buried treasure. He decides to split the treasure among his $$$n$$$ crewmates by running a race and giving rewards based on the race placements.

However, some crewmates realize that they can stand to gain more by forming coalitions and splitting the rewards among all members of a coalition (as bigger coalitions are more likely to have higher placing members).

Edward decides to have his crewmates run a race, take the highest ranking crewmate in each coalation, rank the coalitions in terms of each coalition's highest ranking crewmate, and give every crewmate in the coalition the rank of their coalition. Each crewmate is equally fast, so every single permutation of crewmate race placements is equally likely.

Given this information and the crew members in each of the $$$k$$$ coalitions, output the expected rank of each crew member given Edward Kenway's scheme. Each crew member's expected rank can be expressed as a rational $$$\frac{p}{q}$$$. Output $$$pq^{-1} \pmod {10^9 + 7}$$$ for each crew member.

Input

The first line consists of two integers $$$n, k$$$ $$$(1 \leq k \leq n \leq 250)$$$, giving the number of crewmates and number of coalitions.

The next $$$k$$$ lines each consist of a single integer $$$s_i$$$, giving the size of the $$$i$$$th coalition and the next $$$s_i$$$ integers in the line give all crewmates in that coalition. Every crewmate is guaranteed to be in a coalition.

Output

Output $$$n$$$ integers, where the $$$i$$$th integer is the expected rank of the $$$i$$$th crewmate.

ExamplesInput
5 1
5 1 2 3 4 5
Output
1 1 1 1 1 
Input
5 2
3 1 2 3
2 4 5
Output
800000007 800000007 800000007 200000003 200000003 
Note

In the first sample, every single crewmate belongs to the same coalition, so each crewmate will always be rank $$$1$$$.

In the second sample, there is a $$$\frac{3}{5}$$$ chance that the first coalition is rank $$$1$$$ and a $$$\frac{2}{5}$$$ chance that the second coalition is rank $$$1$$$. All crewmates in the first coalition have an expected rank of $$$1 \cdot \frac{3}{5} + 2 \cdot \frac{2}{5} = \frac{7}{5}$$$ and all crewmates in the second coalition have an expected rank of $$$1 \cdot \frac{2}{5} + 2 \cdot \frac{3}{5} = \frac{8}{5}$$$.

加入题单

算法标签: