Hide

Problem B
Deceitful Dice

Hallvard the high-roller has produced a set of dice that will be used in his new, and exceptionally unfair casino. The set of dice has $K$ faces, and Hallvard knows the probability of each face facing upwards. To make sense of what odds to give the gamblers in his casino, Hallvard must organize the dice according to their expected value.

Given a set of $N$ $K$-sided dice, print out the dices ordered by which dice rolls the highest value on average.

Input

The first line contains two integers, $N$, and $K$, which describes the number of dice, and the number of faces each dice has. Then follow $N$ lines of data, where the $i$th line describes the $i$th dice. Each line consists of the $K$ integers $C_1$ to $C_ K$. $C_ j$ is the percentage of dice rolls that will have the value of $j$. You may assume that all of the percentages for each dice add up to 100.

Output

$N$ numbers, where the first number is the dice that produces the highest value on average, and the second one produces the second highest value on average and so on. If two dice produce the same average, their order should be the same as in the input.

Limits

  • $1 < N, K \leq 100$

  • $0 \leq C_ i \leq 100$

Sample Input 1 Sample Output 1
3 4
48 48 2 2
2 48 48 2
2 2 48 48
3 2 1
Sample Input 2 Sample Output 2
3 6
15 15 15 15 15 25
25 25 0 0 25 25
20 20 10 10 20 20
1 2 3

Please log in to submit a solution to this problem

Log in