main = do
    s <- getLine
    ns <- getLoopIntValues 
    putStr $ foldl shuffle s ns
    putStrLn ""

shuffle :: String -> Int -> String
shuffle s n = drop n s ++ take n s

getLoopIntValues :: IO([Int])
getLoopIntValues = do
    vs <- getLoopValues
    return $ map read vs
    
getLoopValues :: IO([String])
getLoopValues = do
    loopNum <- getInt
    getLoopValues' loopNum

getLoopValues' :: Int -> IO([String])
getLoopValues' 0 = return []
getLoopValues' n = do
    v <- getLine
    vs <- getLoopValues' (n - 1)
    return $ v : vs

getInt :: IO (Int)
getInt = do
    str <- getLine
    return $ read str
