import Data.List (foldl', unfoldr)

main :: IO ()
main = mapM_ print . solve . map read . words =<< getContents

solve :: [Int] -> [Int]
solve (n:_:qs) = let ps = concatMap (uncurry (flip replicate)) $ foldl' f [(n, 1)] qs'
                     in [ length $ filter (>=k) ps | k <- [1..n] ]
  where f xs x = concat $ unfoldr g (x, cycle xs)
        g (a, ((b, c) : ys))
          | a == 0 = Nothing
          | b * c <= a = Just ([(b, c)], (a - b * c, ys))
          | otherwise = Just (filter ((>0).fst) [(b, d), (m, 1)], (0, ys))
          where (d, m) = a `divMod` b
        qs' = let q = minimum qs in q : reverse (takeWhile (/=q) (reverse qs))
solve _ = undefined
