import Control.Monad

shuffle :: [Char] -> [Int] -> [Char]
shuffle s [] = s
shuffle s (h:hs) =
  shuffle (first ++ lst) hs where
    (lst, first) = splitAt h s

main = do
  s <- getLine
  if s == "-" then return ()
  else do
    m <- readLn
    hs <- replicateM m $ fmap read getLine
    putStrLn $ shuffle s hs
    main