import Control.Monad
import Data.Char

solve :: String -> [Int] -> String
solve s xs = foldl (\a x -> drop x a ++ take x a) s xs

main :: IO ()
main = do
    s <- getLine
    if s == "-"
        then return ()
        else do
            n  <- readLn
            xs <- replicateM n readLn
            putStrLn $ solve s xs
            main