This page is still under construction.

Parts of this page are still being built. What you see may change.

Distributing the Treasure

Time limit4sMemory limit1024 MB

Level

Not classified yet

Solved
No attempts yet

Problem

You are the leader of a treasure hunting team. Under your direction, the team succeeded in a quest and obtained a lot of treasure. The only remaining issue is how to distribute the treasure among the team members, and it matters.

The treasure includes a variety of precious items: gold ingots, jewelry with brilliant gemstones, exquisite craft works, and so on. Each team member estimates the values of the items individually. The estimates are consistent: for any pair of items, if some member estimates one strictly higher than the other, no member estimates the opposite. Some members may give equal estimates.

All members are sensible and understand that the items cannot be divided evenly. So no member gets angry merely because the sum of the values in their share, by their own estimate, is lower than another member's share. A member does get angry if their own share is estimated strictly lower than another member's share, even after removing the item with the least estimated value from that other share. Some members may receive nothing as long as they do not get angry.

Decide who receives which items so that no member gets angry.

Input

The first line has two positive integers nn and mm with n×m≤2×105n \times m \le 2 \times 10^5. Here nn is the number of members and mm is the number of treasure items. Members and items are numbered 1 through nn and 1 through mm.

The ii-th of the following nn lines contains mm positive integers, each at most 2×1052 \times 10^5, in descending order: vi,1≥vi,2≥⋯≥vi,mv_{i,1} \ge v_{i,2} \ge \cdots \ge v_{i,m}. Here vi,jv_{i,j} is the value of item jj estimated by member ii.

Output

If the items can be distributed without making any member angry, output mm positive integers x1,x2,…,xmx_1, x_2, \dots, x_m separated by spaces, where xj=ix_j = i means member ii receives item jj. If several distributions are valid, any of them is accepted.

If no distribution avoids anger, output 0 on a line.

Hint

Let Vi(X)V_i(X) denote the sum of the values of the items in set XX as estimated by member ii.

In Sample 1, V1({1,3})V_1(\{1, 3\}) is 4+1=54 + 1 = 5, V1({2})V_1(\{2\}) is 22, V2({1,3})V_2(\{1, 3\}) is 3+3=63 + 3 = 6, and V2({2})V_2(\{2\}) is 33. The output shows a distribution where member 1 is not angry, since V1({1,3})≥V1({2})V_1(\{1, 3\}) \ge V_1(\{2\}). Member 2 is not angry either, even though V2({2})<V2({1,3})V_2(\{2\}) < V_2(\{1, 3\}). If member 1 gives up one of the two items, the remaining share would be worth V2({1})=3V_2(\{1\}) = 3 or V2({3})=3V_2(\{3\}) = 3, and neither is higher than V2({2})=3V_2(\{2\}) = 3.

The shares cannot be swapped. Suppose member 1 receives {2}\{2\} and member 2 receives {1,3}\{1, 3\}. Member 1 is angry because V1({2})=2<4=V1({1})V_1(\{2\}) = 2 < 4 = V_1(\{1\}). Even if member 2 gives up item 3, the lesser item in {1,3}\{1, 3\}, the remaining item 1 is still estimated higher than V1({2})=2V_1(\{2\}) = 2.

In Sample 2, you are the only member, so you take all the items.

Examples2

  1. Example 1

    Input
    2 3
    4 2 1
    3 3 3
    
    Expected output
    1 2 1
    
  2. Example 2

    Input
    1 7
    64 32 16 8 4 2 1
    
    Expected output
    1 1 1 1 1 1 1