while true  
  data = gets
  if data == "0 0\n"
    break
  end
  
  n, r = data.split(nil).map(&:to_i)

  array = []
  n.downto(1) do |i|
    array.push(i)
  end

  while r > 0
    data = gets
    p, c = data.split(nil).map(&:to_i)

    temp = array.slice!(p-1..p-1+c-1)
    array = temp + array
    
    r -= 1
  end

  puts array[0]
end
