import Control.Monad

shuffle :: String -> Int -> String
shuffle cards h = second ++ first
	where
		first = fst $ splitAt h cards
		second = snd $ splitAt h cards

main = do
	s <- getLine
	if s == "-" then return() else do
		m <- readLn
		h <- replicateM m readLn
		putStrLn $ foldl (\acc x -> shuffle acc x) s h
		main