403227: GYM101081 J Optimized RPG

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. Optimized RPGtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Every weekend, Pedro and his friends reunite to play a RPG (Role Playing Game). In a RPG one of the friends, called gamemaster, tell a story in which the other players interact according to some predefined rules and using the results from rolling dice. Pedro, being the most experienced in this game, is always the gamemaster. He always design the games beforehand in order to entertain his friends the most.

The next weekend, Pedro is going to host the continuation of last's weekend game. This time N monsters numbered from 1 to N are going to appear, one after another. The difficulty of a monster is determined by M attributes (strength, speed, intelligence, etc). Now, Pedro must decide against which of these monsters his friends will fight. A sequence of monsters is valid if its indices are in increasing order. Pedro's friends are really intelligent and will be disappointed if they fight against a monster that is not harder than all the monsters that they have already fought. A monster is harder than another monster if it has a higher value in each attribute than the other monster.

Pedro would like the game to last as long as possible. He knows you compete in programming contests, so he asked for your help. You have to choose a subset, with the biggest number of monsters possible, to battle against your friends (obeying the restrictions given before).

Input

The first line has two integers M and N, the number of attributes and monsters, respectively. The following M lines will contain N integers each. The jth integers in the ith line represents the value of the jth attribute of the ith monster.

Limits

  • 1 ≤ M ≤ 10
  • 1 ≤ N ≤ 105
  • If M > 2 then N ≤ 103
  • The value of an attribute of a monster is between 0 and 109
Output

Print a line containing the indices of the monsters, in order of difficulty. If there are multiple answers, any one will be accepted.

ExamplesInput
3 4
1 2 9 7
1 3 4 9
1 9 5 6
Output
1 2 
Input
4 4
0 3 3 4
0 1 2 4
0 2 1 4
0 3 3 4
Output
1 3 4 

Source/Category

加入题单

算法标签: