while true do
  n, r = gets.split.map(&:to_i)
  break if n == 0 && r == 0

  p = Array.new(r)
  c = Array.new(r)
  r.times do |i|
    p[i], c[i] = gets.split.map(&:to_i)
    p[i] = p[i].pred
  end

  res = Array.new(n){|i| n - i}

  r.times do |i|
    res[0, n] = res[p[i], c[i]] + res[(0...p[i])] + res[((p[i] + c[i])...res.size)]
  end

  p res
end