import Control.Applicative
import Control.Monad
main = do
  s <- getLine
  if s == "-" then return ()
              else do
                n <- (read::(String->Int)) <$> getLine
                v <- replicateM n getLine
                let vv = map read v :: [Int]
                putStrLn $ shuf s vv
                main

shuf :: String -> [Int] -> String
shuf s [] = s
shuf s (x:xs) = shuf (aux s x) xs 
    where
      aux :: String -> Int -> String
      aux s n = (drop n s) ++ (take n s)