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

main = do
  ns <- fmap (fmap (read :: String -> Int) . words) . lines <$> getContents
  let n = head $ head ns
  let ls = group $ sort $ concat $ tail ns
  let res = reverse $ solve n ls
  forM_ res putStrLn

solve :: Int -> [[Int]] -> [String]
solve 0 ls = []
solve n ls =  makeAns n ls : solve (subtract 1 n) ls

makeAns :: Int -> [[Int]] -> String
makeAns n ls
  | elem n $ concat ls = show $ length $ head $ filter (\ns -> head ns == n) ls
  | otherwise = "0"