-- String - Shuffle

import Control.Monad

main :: IO ()
main = do
  cs <- getLine
  when (cs /= "-") $ do
    m <- readLn
    hs <- replicateM m getLine
    putStrLn $ foldl shuffle cs $ map read $ hs
    main

shuffle :: String -> Int -> String
shuffle cs h = bs ++ as
  where (as, bs) = splitAt h cs

