while true
    n, r = gets.chomp.split.map(&:to_i)
    break if [n, r] == [0, 0]
    cards = (1..n).to_a.reverse
    r.times{
        p, c = gets.chomp.split.map(&:to_i)
        cards = cards[p - 1, c] + cards[0, p - 1] + cards[(p - 1 + c) .. -1]
    }
    puts cards[0]
end
