import Control.Applicative
import Control.Monad

shuffle :: Int -> String -> String
shuffle h cs = (drop h cs) ++ (take h cs)

shuffles :: [Int] -> String -> String
shuffles (h:hs) cs
    | length (h:hs) == 1 = shuffle h cs
    | otherwise          = shuffles hs (shuffle h cs)

main :: IO()
main = do
    cs <- getLine
    if (cs == "-")
    then return ()
    else do
        m <- read <$> getLine
        hs <- replicateM m (read <$> getLine)
        putStrLn $ shuffles hs cs
        main