Dream Team

View as PDF

Submit solution

Points: 100
Time limit: 2.0s
PyPy 3 3.0s
Python 3 3.0s
Memory limit: 1G

Author:
Problem type

The MAPS sports committee could not agree on which events to include in its relay, so it included all of them. Welcome to the N-athlon: N different legs, ranging from running and swimming to whatever sport the committee discovers next.

Your team has exactly N people, numbered from 1 to N. The legs must be completed in order from 1 to N, with exactly one person completing each leg and each person competing exactly once. Person i takes T_{i,j} seconds to complete leg j. Each leg starts as soon as the previous leg finishes, and changing competitors takes no time.

Everyone wants to compete in their favourite event. You would prefer to win. Choose an order for your team that minimises the total time needed to complete all N legs.

Input

The first line contains an integer N (1 \le N \le 10), the number of people and the number of legs.

Each of the next N lines contains N integers. The j-th integer on the i-th of these lines is T_{i,j} (1 \le T_{i,j} \le 10^6), the time in seconds that person i takes to complete leg j.

Output

Print N space-separated integers p_1, p_2, \ldots, p_N, where p_j is the person assigned to leg j. Every integer from 1 to N must appear exactly once.

The sum T_{p_1,1} + T_{p_2,2} + \cdots + T_{p_N,N} must be as small as possible. If several orders achieve the minimum total time, print any of them.

Example 1

Input
3
1 2 9
2 9 9
9 1 2
Output
2 1 3
Explanation

Assigning people 2, 1, and 3 to the three legs takes 2 + 2 + 2 = 6 seconds. Although person 1 is fastest at the first leg, assigning them there would prevent this minimum total.

Example 2

Input
1
7
Output
1
Explanation

There is only one person and one leg, so there is only one possible order.

Example 3

Input
2
5 5
5 5
Output
2 1
Explanation

Both orders take 10 seconds. The order 1 2 would also be accepted.


Comments

There are no comments at the moment.