Distributing the Treasure

아직 제출이 없습니다시간 제한4초메모리 제한1024 MB

문제

You are the leader of a treasure hunting team. Under your great direction, your team has made a big success in a quest, and got a lot of treasure. The only, but crucial, remaining issue is how to distribute the obtained treasure to the team members.

The excavated treasure includes a variety of precious items: gold ingots, jewelry with brilliant gem stones, exquisite craft works, etc. Each team member individually estimates the values of the items. The estimated values are consistent, in that, for any pair of two items, when some member estimates one to be strictly higher than the other, no member estimates oppositely, although some may give equal estimates.

All the members are sensible and thus understand the difficulty of even distribution of the items. Hence, no member will complain simply because, based on the member’s own estimation, the sum of the values of the member’s share is lower than that of another member’s share. The members, however, may get angry if their own shares look unreasonably shabby compared to some other member’s; what they cannot stand is when their own shares are estimated strictly lower than the share of that other member even after getting rid of one item with the least estimated value.

Your last mission as the leader is to decide who receives which items so that no member gets angry. Some of the members may receive nothing as long as they do not get angry.

입력

The input consists of a single test case of the following format.

\begin{align\*}& n \\, m \\\ & v\_{1,1} \\, \cdots \\, v\_{1, m} \\\ & \vdots \\\ & v\_{n,1} \\, \cdots \\, v\_{n,m} \end{align\*}

The first line of the input has two positive integers nn and mm whose product does not exceed 2×1052 × 10^5; nn is the number of members of your treasure hunting team, and mm is the number of treasure items. The members and items are numbered 11 through nn and 11 through mm, respectively. The ii-th of the following nn lines has mm positive integers not exceeding 2×1052 × 10^5 in descending order: v_i,1v_i,2v_i,mv\_{i,1} ≥ v\_{i,2} ≥ \cdots ≥ v\_{i,m}. Here, v_i,jv\_{i,j} is the value of the item jj estimated by the member ii.

출력

If you can distribute the items to the members without making any member angry, output such a distribution in a line as mm positive integers x_1x\_1, x_2x\_2, \dots, x_mx\_m separated by spaces. Here, x_j=ix\_j = i means that the member ii receives the item jj. If two or more such distributions exist, any of them shall be deemed correct. If there is no way to distribute the items without making any member angry, just output 0 in a line.

힌트

Let V_i(X)V\_i(X) denote the sum of the values of items in the set XX estimated by the member ii.

In Sample 1, V_1(1,3)V\_1(\\{1, 3\\}) is 4+1=54 + 1 = 5, V_1(2)V\_1(\\{2\\}) is 22, V_2(1,3)V\_2(\\{1, 3\\}) is 3+3=63 + 3 = 6, and V_2(2)V\_2(\\{2\\}) is 33. The distribution shown as output does not make the member 11 angry as V_1(1,3)V_1(2)V\_1(\\{1, 3\\}) ≥ V\_1(\\{2\\}). The member 22 does not get angry either even though V_2(2)<V_2(1,3)V\_2(\\{2\\}) < V\_2(\\{1, 3\\}) holds. If the member 11 waives one of the two items, the sum of the values of items received by the member 11 would become V_2(1)=3V\_2(\\{1\\}) = 3 or V_2(3)=3V\_2(\\{3\\}) = 3, neither of which is higher than V_2(2)=3V\_2(\\{2\\}) = 3.

Note that their shares should not be exchanged. Suppose that the member 11 receives 2\\{2\\} and the member 22 receives 1,3\\{1, 3\\}. This makes the member 11 angry because V_1(2)=2<4=V_1(1)V\_1(\\{2\\}) = 2 < 4 = V\_1(\\{1\\}) holds, meaning that, even if the member 22 waives the item 33, which is estimated to be the lesser of 1,3\\{1, 3\\}, the value of the sole remaining item 11 is still estimated higher than V_1(2)=2V\_1(\\{2\\}) = 2.

In Sample 2, you are the sole member of your team, so you can take them all. Congratulations!