while true do
  n, r = gets.split.map(&:to_i)
  break if n == 0 && r == 0
  t = []
  r.times do |i|
    t << gets.split.map(&:to_i)
  end
  res = (0...n).to_a
  # p n, r, t, res, res[0]
  # puts
  
  for i, j in t
    res << res[-i - j + 1..-i]
    res = res.flatten()
    res[-i - j + 1 - j..-i - j] = []
    res = res.flatten()
  end
  p res[-1] + 1

end