while line = gets
  n, r = line.split(" ").map(&:to_i)
  break if n == 0
  yama = [*1..n].reverse
  r.times {
    p, c = gets.split(" ").map(&:to_i)
    cut = yama[p-1, c]
    yama = cut + (yama - cut)
  }
  p yama[0]
end