Under construction

Still being built. Things may change

Bingo for the Win!

Time limit1sMemory limit1024 MB

Summary
Given each player's bingo sheet and a uniformly random calling order, find the probability that each player is the last to finish under Speed Bingo rules.
Level

Hard8 of 10

Topics
Probability, Combinatorics, Hash map, Dynamic programming
Solved
No attempts yet

Problem

Bingo is a game of chance for multiple players. Each player receives a sheet with some numbers, and a game master calls out these numbers in a random order. Players cross off the numbers they have heard, and the first player to cross off all their numbers wins the game. This basic version is fairly sedate. Players only need to stay awake.

In this problem we analyze a more dynamic version called Speed Bingo. The game master also calls out the numbers on the sheets in a random order. However, whenever a number is called, only the first player to signal that they have that number may cross it off their sheet. If a player has the same number multiple times, only one copy may be crossed off at a time. When several players have the same number, the player with the fastest reaction time has the advantage. But how big is that advantage? Finding out is the goal of this problem.

There are nn players, each receiving a sheet of kk numbers. The numbers may repeat, and different players may receive different sheets. Player 11 reacts faster than player 22, who reacts faster than player 33, and so on, with player nn being the slowest. The following figure shows three players who each receive four numbers:

When the number 11 is called for the first time, player 11 crosses it off, since player 11 is faster. When 11 is called the second time, player 22 crosses it off. On average, player 11 is expected to do better than players 22 and 33, because both of them need numbers that player 11 reaches first. Players 22 and 33 share no numbers, so their results are independent of each other, even though player 22 is faster than player 33.

Suppose the game continues until every player has crossed off all of their numbers, that is, until all n⋅kn \cdot k numbers on all sheets (counting repeats) have been read. If the order of the numbers is uniformly random, what is the probability that each player finishes last?

Input

The input describes a single game of Speed Bingo. The first line contains two integers nn and kk, the number of players and the number of numbers on each sheet (1≤n≤1001 \le n \le 100, 1≤k≤10001 \le k \le 1000). The next nn lines each contain kk integers. The iith line gives the numbers on the sheet of the iith player. All numbers are between 11 and 10910^9, inclusive.

Output

Output nn lines, one for each player. The iith line contains the probability that player ii finishes last. All values must be accurate to an absolute error of at most 10−610^{-6}.

Examples2

  1. Example 1

    Input
    3 4
    1 2 3 4
    1 2 5 6
    3 4 7 8
    
    Expected output
    0.000000000
    0.500000000
    0.500000000
    
  2. Example 2

    Input
    4 2
    1 2
    3 4
    10 5
    7 8
    
    Expected output
    0.250000000
    0.250000000
    0.250000000
    0.250000000