import Control.Monad
import Control.Applicative

strShuffle s i = drop i s ++ take i s

main = do
    strLn <- getLine
    if strLn == "-" then return () else do
        n <- read <$> getLine
        shuffles <- replicateM n $ read <$> getLine :: IO [Int]
        putStrLn $ foldl strShuffle strLn shuffles
        main