import Control.Applicative
import Control.Monad
import Data.Char

shuf :: [Int] -> String -> String
shuf [] x = x
shuf (h:hs) x = let r = shuf hs x in drop h r ++ take h r

main = do
  w <- getLine
  if(w == "-") then return()
  else do
    m <- readLn ::IO Int
    h <- replicateM m readLn :: IO [Int]
    putStrLn $ shuf (reverse h) w
    main