import Control.Applicative
    
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
                n <- read <$> getLine
                shuffles <- inputShuffles n []
                inputProblem $ problem ++ [(text, shuffles)]
        
inputShuffles :: Int -> Shuffles -> IO Shuffles

inputShuffles 0 shuffles
    = return shuffles
    
inputShuffles n shuffles
    = do
        index <- read <$> getLine
        inputShuffles (n - 1) $ shuffles ++ [index]

main :: IO ()

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