import Control.Monad

shuffle :: String -> [Int] -> String
shuffle res [] = res
shuffle s (n:l) = shuffle (drop n s ++ take n s) l

main = do
  l <- getLine
  if l == "-" then return ()
  else do
    n <- getLine
    s <- replicateM (read n) getLine
    putStrLn $ shuffle l (map read s)
    main