import Control.Applicative

import Control.Monad
    (replicateM)
    
import Data.List
    (intersperse)
    
type Shuffles = [Int]

type Problem = [(String, Shuffles)]

type Result = [String]

shuffle :: String -> Int -> String

shuffle text index
    = (drop index text) ++ (take index text)
    
solve :: Problem -> Result

solve problem
    = map (\(t, s) -> foldl shuffle t s) problem

output :: Result -> String

output result
    = concat $ intersperse "\n" result
    
input :: IO Problem

input
    = inputProblem []
        
inputProblem :: Problem -> IO Problem

inputProblem problem
    = do
        text <- getLine
        if text == "-"
            then return problem
            else do
                shuffles <- inputShuffles
                inputProblem $ problem ++ [(text, shuffles)]
        
inputShuffles :: IO Shuffles
    
inputShuffles
    = do
        n <- read <$> getLine
        shuffles <- replicateM n $ read <$> getLine
        return shuffles

main :: IO ()

main
    = putStr.output =<< solve <$> input