loop do
    word = gets.chomp.split("").map do |s| s.to_s end
    if word[0] == "-"
        break
    end
    time =  gets.chomp.to_i
    time.times do |n|
        shift = gets.chomp.to_i
        word.rotate!(shift)
    end
    puts word.join("")
end