while true
  n_r = gets.split(' ').map {|i| i.to_i}
  n = n_r[0]
  r = n_r[1]
  break if n == 0 && r == 0
  p_cs = []
  r.times do |_|
    p_cs << gets.split(' ').map {|i| i.to_i} 
  end

  place_of_top = 1
  until p_cs.empty?
    p_c = p_cs.pop
    p = p_c[0]
    c = p_c[1]
    case place_of_top
    when 1..c
      place_of_top += p - 1
    when (c+1)..(p + c - 1)
      place_of_top -= c
    end
  end
  puts n + 1 - place_of_top
end