{-#LANGUAGE BangPatterns#-}
module Main where

import Data.Functor
import Control.Monad
import Data.List

main::IO ()
main=do
   [m,n]<- map read . words <$> getLine::IO [Int]
   unless (m<=0 && n<=0) $
     do
       input<-replicateM m (map read . words <$> getLine)::IO [[Int]]
       let input'=zip [1..] (map length $ cross input n)::[(Int,Int)]
           out=unwords . map (show . fst) $ sortBy func input'
       putStrLn out
       main
  where
    func (_,a) (_,b)=compare a b

cross::[[a]]->Int->[[a]]
cross=cross' []
  where
    cross'::[[a]]->[[a]]->Int->[[a]]
    cross' v l 0=v
    cross' v l !m=
      let (xs,xss)=(map head l,map tail l) in
      cross' (xs:v) xss (m-1)