import Control.Monad (replicateM, forM_)
import Data.List (sort, group)

main = do
  [n, m] <- fmap read <$> words <$> getLine :: IO [Int]
  xss <- fmap (fmap read) <$> fmap words <$> replicateM m getLine :: IO [[Int]]
  forM_ (fmap (show . length) . group . sort . concat $ xss) putStrLn
