while n = gets
  n = n.split(" ").map(&:to_i)
  if n[0] != 0
  card = []
  for i in 0 ... n[0]

    card[i] = n[0] - i
  end

  b = []

  for i in 0 ... n[1]

    m = gets.split(" ").map(&:to_i)
    m[0] = m[0] - 1


    new = card[m[0]..m[0]+m[1]-1]
    card.slice!(m[0],m[1])
    new.push(card)
    card = new.flatten
    #puts card[0]
end

  puts card[0]

  card.slice!(0,card.length)

  new.slice!(0,new.length)
  end
end

