import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.Char

rotate s n = drop n s ++ take n s

main = do
    s <- getLine
    when (s /= "-") $ do
        m <- readLn
        replicateM m readLn >>= putStrLn . foldl rotate s 
        main