During a programming contest, the contestants face an unexpected problem: the judging system (judge) has failed and can no longer evaluate the submissions correctly. However, the contest website had prepared for this eventuality by implementing an alternative judge. This alternative judge, for each submission, randomly selects one of the possible verdicts with equal probability.
However, each contestant has restrictions regarding the verdicts they can receive. For example, competitor Gabmei can never receive the "Wrong Answer" (WA) verdict. Thus, for each submission, the system randomly selects, with equal probability, among the verdicts allowed for that particular contestant.
Given that there are M contestants in the competition—each with their own list of possible verdicts (from among the K available verdicts)—and that N submissions have been made (knowing which contestant made each submission), determine the expected frequency of each verdict at the end of the contest.
The first line of the input contains three integers:
Then, 2 * M lines are provided regarding the contestants.
For each of the M competitors:
Finally, N lines follow, each containing the index of the contestant who made the i-th submission $$$(1 \leq i \leq N)$$$.
Output a vector of size K, where the i-th element epresents the expected frequency of verdict i ao final da competição. Cat the end of the contest. Each value must be displayed with at least 6 decimal places.
4 1 441 2 3 41111
1.000000 1.000000 1.000000 1.000000
2 2 531 2 331 2 312
0.666667 0.666667 0.666667 0.000000 0.000000