while true
    str = gets.chomp
    if str == "-"
        break
    else
        gets.to_i.times do
            shuflle_start_index = gets.to_i
            str = str[shuflle_start_index...str.size] + str[0...shuflle_start_index]
        end
        puts str
    end
end
