loop do
    n = gets.chomp
    if n == "-"
        break
    end
    m = gets.chomp.to_i
    m.times do
        h = gets.chomp.to_i
        first = n[0...h]
        second = n[h..-1]
        n = second + first
    end
    puts n
end