import Control.Monad

main = do
    w <- getLine
    if w == "-"
        then return ()
        else do
            shuffleWord w
            main

shuffleWord w = do
    sm <- getLine
    let nm = read sm :: Int
    shufflesS <- replicateM nm getLine
    let shufflesN = map (\x -> read x :: Int) $ shufflesS
    let result = foldl shuffle w shufflesN
    putStrLn result

shuffle :: String -> Int -> String
shuffle w n = (drop n w) ++ (take n w)
