def shuffle(cards,shuffleNum)
    cards[shuffleNum..-1] +cards[0..shuffleNum-1]
end
while true do
    cards = gets.chomp
    break if cards=="-"
        num = gets.to_i
        num.times   do
        shuffleNum =gets.to_i
        cards = shuffle(cards,shuffleNum)      

                    end
        if cards[-1]=="-"
    puts cards
else
    puts cards[0..-1]
        end
end

