
class String
  def integer?
    true if Integer(self) rescue false
  end
end

loop do
    w = gets.chomp
    if w.eql?("-") then
        break
    end
    
    n = gets.chomp.to_i
    
    n.times do |i|
        p = gets.chomp.to_i
        k = w.slice!(0...p)
        w = w + k
    end

    print w, "\n"
end

