loop {
    n, r = gets.split.map &:to_i
    break if n == 0
    a = (1..n).to_a.reverse
    r.times {
        p, c = gets.split.map &:to_i
        a = a[p-1..p-2+c] + (p > 1 ? a[0..p-2] : []) + a[p-1+c..n-1]
    }
    p a[0]
}