import Control.Applicative
import Control.Monad
import Data.List

main = do
  [n,m] <- map read.words<$>getLine
  unless (n == 0 && m == 0) $ do
    ans <- replicateM n $ map read.words<$>getLine
    putStrLn.unwords.map (show.fst).sortBy (\x y -> compare (snd y) (snd x)).addUp $ ans
    main

addUp :: [[Int]] -> [(Int, Int)]
addUp = zip [1..].foldl1 (zipWith (+))