module Main where
--import Debug.Trace
import Data.List
import Data.Char
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: [(String,Int, [Int])] -> [String]
solve [] = []
solve ((w,n,sl):xs) = (suffle w sl):solve xs where
    suffle w [] =  w
    suffle w (s:sl) = suffle (drop s w ++ take s w) sl

readUntil :: (String -> Bool) -> IO [(String,Int, [Int])]
readUntil eof = iter where
    iter = getLine >>= (\w -> 
            if eof w then return []
                     else do
                        n <- readLn
                        ls <- replicateM n getLine
                        let l = map read ls
                        fmap ((w,n,l):) iter)

eof :: String -> Bool
eof s = s == "-"

main :: IO() 
main = do
    l   <- readUntil eof
    mapM_ putStrLn (solve l)

