cond = [int(n) for n in input().split(" ")]



while True:

    case = []

    cards = [n for n in range(1,cond[0] + 1)]

    cards.sort(reverse = True)

    for c in range(cond[1]):

        case = [int(n) for n in input().split(" ")]

        case[0] -= 1

        #print(cards[case[0]:case[0]+case[1]],cards[case[1]:case[0]+case[1]],cards[:case[1]],cards[:case[1]])

        disp = cards[case[0]:case[0]+case[1]]

        cards[case[1]:case[0]+case[1]] = cards[0:case[0]]

        cards[0:case[1]] = disp

    else:

        print((cards[0]))

        cond = [int(n) for n in input().split(" ")]

        if cond[0] == 0 and cond[1] == 0:

            break

        else:

            continue
cards,trial = (int(n) for n in input().split(" "))

while True:

    cards = list(reversed([int(n) for n in range(1,(cards)+1)]))

    for n in range(trial):

        num,change = (int(n) for n in input().split(" "))

        num -= 1

        disp = cards[num:num+change]

        cards[change:change+num] = cards[:num]

        cards[:change] = disp

    print((cards[0]))

    cards,trial = (int(n) for n in input().split(" "))

    if cards == 0 and trial == 0:

        break
cond = [int(n) for n in input().split(" ")]
while True:
    case = []
    cards = [n for n in range(1, cond[0] + 1)]
    cards.sort(reverse=True)
    for c in range(cond[1]):
        case = [int(n) for n in input().split(" ")]
        case[0] -= 1
        # print(cards[case[0]:case[0]+case[1]],cards[case[1]:case[0]+case[1]],cards[:case[1]],cards[:case[1]])
        disp = cards[case[0] : case[0] + case[1]]
        cards[case[1] : case[0] + case[1]] = cards[0 : case[0]]
        cards[0 : case[1]] = disp
    else:
        print((cards[0]))
        cond = [int(n) for n in input().split(" ")]
        if cond[0] == 0 and cond[1] == 0:
            break
        else:
            continue

cards, trial = (int(n) for n in input().split(" "))
while True:
    cards = list(reversed([int(n) for n in range(1, (cards) + 1)]))
    for n in range(trial):
        num, change = (int(n) for n in input().split(" "))
        num -= 1
        disp = cards[num : num + change]
        cards[change : change + num] = cards[:num]
        cards[:change] = disp
    print((cards[0]))
    cards, trial = (int(n) for n in input().split(" "))
    if cards == 0 and trial == 0:
        break

-cond = [int(n) for n in input().split(" ")] +cards, trial = (int(n) for n in input().split(" ")) -    case = [] -    cards = [n for n in range(1, cond[0] + 1)] -    cards.sort(reverse=True) -    for c in range(cond[1]): -        case = [int(n) for n in input().split(" ")] -        case[0] -= 1 -        # print(cards[case[0]:case[0]+case[1]],cards[case[1]:case[0]+case[1]],cards[:case[1]],cards[:case[1]]) -        disp = cards[case[0] : case[0] + case[1]] -        cards[case[1] : case[0] + case[1]] = cards[0 : case[0]] -        cards[0 : case[1]] = disp -    else: -        print((cards[0])) -        cond = [int(n) for n in input().split(" ")] -        if cond[0] == 0 and cond[1] == 0: -            break -        else: -            continue +    cards = list(reversed([int(n) for n in range(1, (cards) + 1)])) +    for n in range(trial): +        num, change = (int(n) for n in input().split(" ")) +        num -= 1 +        disp = cards[num : num + change] +        cards[change : change + num] = cards[:num] +        cards[:change] = disp +    print((cards[0])) +    cards, trial = (int(n) for n in input().split(" ")) +    if cards == 0 and trial == 0: +        break