while true
    a = gets.split().map {|x| x.to_i}
    if a[0]==0 and a[1]==0 then
        break
    end

    deck = []
    for i in 1..a[0] do
        deck << i
    end
    for i in 1..a[1] do
        spam = gets.split().map {|x| x.to_i}
        tmp = deck.slice!((-spam[0]-spam[1]+1)..-spam[0]) 
        deck = deck + tmp
    end
    puts deck[deck.length-1]
end