import Control.Monad

transmigration h str = drop h str ++ take h str

shuffle str [] = str
shuffle str (h:hs) = shuffle str1 hs
  where
    str1 = transmigration h str

main = do
  str <- getLine
  when (str /= "-") $ do
    m <- readLn
    h <- replicateM m readLn
    print $ shuffle str h
    main