import Data.Char
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as MV


main = do
  dataSet <- fmap lines getContents
  let strings = map (\(s,hs) -> shuffleLoop hs (V.fromList s)) . disassembe $ dataSet
  mapM_ (putStrLn . V.toList) strings
  -- putStrLn ""

shuffleLoop [] vector = vector
shuffleLoop (h:hs) vector = shuffleLoop hs (shuffle h vector)

shuffle h vector = newVec
  where
    (fstVec,sndVec) = V.splitAt h vector
    newVec = sndVec V.++ fstVec

disassembe list = loop list []
  where
    loop ["-"] stack = stack
    loop (s:m:xs) stack = loop ys (stack ++ [(s,map read hs :: [Int])])
      where
        (hs,ys) = splitAt (read m :: Int) xs

