import Data.Char

stringToInt :: String -> [Int]
stringToInt = map digitToInt

create :: [Int] -> Int -> Int -> [Int] -> [Int]
create [] bfr cnt res = res ++ [cnt] ++ [bfr]
create (w:ws) bfr cnt res   | w == bfr  = create ws w (cnt+1) res
                            | otherwise = create ws w 1 $ res ++ [cnt] ++ [bfr]

create' :: [Int] -> [Int]
create' lst = create (tail lst) (head lst) 1 []

loop :: [Int] -> Int -> [Int]
loop lst 0 = lst
loop lst n = loop (create' lst) (n-1)

resulve :: String -> Int -> String
resulve str n =  foldl (++) [] $ map show $ loop (stringToInt str) n

main = do
    l <- getLine
    if l /= "0" then do
        m <- getLine
        putStrLn (resulve m (read l))
        main
    else return ()