import Control.Applicative
import Data.Function
import Control.Monad
import Data.List
import Data.Char

shuffle s [] = s
shuffle s (h:hs) = shuffle ((drop h s) ++ (take h s)) hs

main :: IO ()
main = fix $ \loop -> do
    s <- getLine
    unless (s == "-") $ do
        m <- readLn
        hs <- replicateM m readLn
        putStrLn $ shuffle s hs
        loop
