--import Control.Applicative
import Control.Monad
import Data.Functor
import Data.Monoid
import Data.Maybe
import Data.List

getInts = map read . words <$> getLine :: IO [Int]
sjoin = unwords . map show

fizzBuzz = let fb k s n = guard (n`mod`k==0) $> s in fromMaybe <$> show <*> fb 3 "Fizz" <> fb 5 "Buzz"

f m ss = f' [1..m] $ zipWith (==) ss $ map fizzBuzz [1..]
  where
    f' [p] _ = [p]
    f' ps [] = sort ps
    f' (p:ps) (b:subs) = f' (if b then ps ++ [p] else ps) subs

main = do
    [m,n] <- getInts
    unless (n==0 && m==0) $ replicateM n getLine >>= putStrLn . sjoin . f m >> main
