import Control.Applicative
import Control.Monad

shuffle :: String -> Int -> String
shuffle str h = drop h str ++ take h str

solver :: String -> [Int] -> String
solver = foldl shuffle


main :: IO()
main = do
  str <- getLine
  unless (str == "-") $ do
    m <- (read :: String -> Int) <$> getLine
    hs <- map (read :: String -> Int) <$> replicateM m getLine
    putStrLn $ solver str hs
    main