# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1129&lang=jp

while arr = gets.split(" ").map(&:to_i)
  n , r = arr
  break if n == 0 && r == 0
  arr = n.times.map{|i| i+1}
  r.times.each do
    p, c = gets.split(" ").map(&:to_i)
    pick = arr.slice!(n-p-c+1, c)
    arr = arr + pick
  end
  p arr.last
end