import Control.Monad

main :: IO ()
main = do
  str <- getLine
  if str == "-" then return () else do
    m <- readLn
    hs <- replicateM m readLn
    putStrLn $ take (length str) . drop (sum hs) $ cycle str
    main