while true do
  n, r = gets.split.map(&:to_i)
  break if n == 0

  operations = []
  r.times do
    operations << gets.split.map(&:to_i)
  end
  pos = 1
  operations.reverse.each do |p, c|
    if c >= pos
      pos += p - 1
    elsif p >= pos
      pos -= c
    end
  end
  puts n - pos + 1
end