import Control.Monad

solve :: String	-> [Int] -> String
solve xs (i:is)
  | null is = xs
  | otherwise	= solve (drop i xs ++ take i xs) is

main = do
  xs <- getLine
  if xs == "-" then return () else do
    n <- readLn	
    s <- replicateM n readLn
    putStrLn $ solve xs	(s ++ [1])
    main