Go: package main

import "fmt"

func main() {
	var n, r int
	fmt.Scan(&n, &r)
	for n != 0 || r != 0 {
		arr := make([]int, n)
		for i := range arr {
			arr[i] = len(arr) - i
		}

		for i := 0; i < r; i++ {
			var p, c int
			fmt.Scan(&p, &c)
			mid, top, last := arr[:p-1], arr[p-1:p-1+c], arr[p-1+c:]
			arr = append(append(append([]int{}, top...), mid...), last...)
		}
		fmt.Println(arr[0])
		fmt.Scan(&n, &r)
	}
}

Python: while True:
    (n, r) = [int(x) for x in input().split()]
    if n==0 and r==0:
        exit()
    cards = [n-i for i in range(n)]
    for _ in range(r):
        (p, c) = [int(x) for x in input().split()]
        cards = cards[p-1:c] + cards[p-1:p-1+c] + cards[p-1+c:]
    print(cards[0])

Python: 
while True:
    num_cards, num_repeat = map(int, input().split())

    if num_cards == 0 and num_repeat == 0:
        break

    # ??±??? [n, n-1, ... , 1]
    cards = list(range(num_cards, 0, -1))

    for _ in range(num_repeat):
        p, c = map(int, input().split())
        cards = cards[p-1:p-1+c] + cards[:p-1] + cards[p-1+c:]

    print(cards[0])

Python: import sys

while 1:
    n, r = map(int, sys.stdin.readline().split())

    if (n, r) == (0, 0):
        break

    yama = [int(n - i) for i in range(n)]

    for lp in range(r):
        p, c = map(int, sys.stdin.readline().split())
        p -= 1
        yama = yama[p:p + c] + yama[:p] + yama[p + c:]

    print(yama[0])

Python: while 1:
    n,r = map(int, input().split())
    if n == r == 0:
        break
    a = list(range(1,n+1))[::-1]
    for i in range(r):
        p,c = map(int, input().split())
        p -= 1
        a = a[p:p+c]+a[:p]+a[p+c:]
    print(a[0])

Python: while True:
    n, r = map(int, input().split())
    if n == 0 and r == 0:
        break
    cards = [n-i for i in range(n)]
    for i in range(r):
        p, c = map(int, input().split())
        cards = cards[p-1:p-1+c] + cards[:p-1] + cards[p-1+c:]
    print(cards[0])

Python: while 1:
    count, times = [int(a) for a in input().split()]
    hanahuda = [i+1 for i in range(count)]
    if count == times == 0:break
    for i in [0]*times:
        p,c = [int(i) for i in input().split()]
        for i in [0]*c:hanahuda.append(hanahuda.pop(count-(p+c)+1))
    print(hanahuda.pop())

Python: class Deck:

    def __init__(self, card_num):
        self.deck_list = self.make_deck(card_num)

    def make_deck(self, card_num):
        deck_list = [None] * card_num
        order = 0
        for i in reversed(range(1, card_num + 1)):
           deck_list[order] = i
           order += 1
        return deck_list

    def shuffled(self, cut_pos1, cut_pos2):
        above_card = self.deck_list[0:cut_pos1]
        below_card = self.deck_list[cut_pos1:cut_pos2]
        remain_card = self.deck_list[cut_pos2:]
        self.deck_list = below_card + above_card + remain_card


def get_two_int():
    two_int = input().split()
    for i in range(2):
        two_int[i] = int(two_int[i])
    return two_int


if __name__ == "__main__":
    while True:
        card_num, shuffle_num = get_two_int()
        if card_num == shuffle_num == 0:
            break
        deck = Deck(card_num)
        for i in range(shuffle_num):
            c, p = get_two_int()
            cut_pos1 = c - 1
            cut_pos2 = c - 1 + p
            deck.shuffled(cut_pos1, cut_pos2)
        print(deck.deck_list[0])

Python: #hanafuda
N,r=(int(i) for i in input().split())
while N!=0 or r!=0:
    H=[int(N-i) for i in range(N)]
    for i in range(r):
        p,c=(int(i) for i in input().split())
        T=[]
 #       print(H)
        for j in range(p-1,p+c-1):
  #          print("T")
            T.append(H[p-1])
            H.pop(p-1)
        H=T+H
    print(H[0])
    N,r=(int(i) for i in input().split())

Python: import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**3
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    while True:
        n,r = LI()
        if n == 0:
            break
        a = list(range(n))
        for _ in range(r):
            p,c = LI()
            a = a[p-1:p-1+c] + a[:p-1] + a[p-1+c:]
        rr.append(n - a[0])

    return '\n'.join(map(str, rr))


print(main())

Python: while True:
    n, r = map(int, raw_input().split())
    if n == 0 and r == 0:
        break

    l = []
    for i in range(1, n + 1):
        l.append(i)

    for i in range(0, r):
        p, c = map(int, raw_input().split())
        tmp = l[len(l) - p + 1:len(l)]
        del l[len(l) - p + 1:len(l)]
        l[len(l) - c:len(l) - c] = tmp

    print(l[len(l) - 1])

Python: n, r = map(int, input().split())
while n != 0:
        hanafuda = list(range(1,n+1))[::-1]
        for _ in range(r):
                p, c = map(int, input().split())
                hanafuda = hanafuda[p-1:p+c-1] + hanafuda[:p-1] + hanafuda[p+c-1:]
        print(hanafuda[0])
        n, r = map(int, input().split())

Python: while True:
    n, r = list(map(lambda x: int(x), input().split(" ")))
    if n == 0 and r == 0:
        break
    cards = [i for i in range(1,n+1)]
    cards = cards[::-1]

    for i in range(r):
        print(cards)
        p, c = list(map(lambda x: int(x), input().split(" ")))
        p -= 1
        cards = cards[p:p+c] + cards[0:p] + cards[p+c:]
    
    print(cards[0])

Python: while True:
	sousa=input().sprit() #?????????
	sousa=[int(sousa[0]),int(sousa[1])]
	if sousa==[0,0]:break
	yama=[]
	for k in range(sousa[0]):yama.append(k+1)
	yama=yama[::-1]
	for r in range(sousa[1]):
		[p,c]=input().sprit()
		[p,c]=[int(p),int(c)]
		yama[:p+c-1]=yama[p-1:p+c-1]+yama[:p-2]
	print(yama[0])

Python: while True:
    n, r = map(int, input().split())
    if n == r == 0:
        break
    cards = [i + 1 for i in range(n)]
    for _ in range(r):
        p, c = map(int, input().split())
        swap = []
        for i in range(c):
            swap.append(cards.pop(n - p - i))
        for i in swap[::-1]:
            cards.append(i)
    print(cards[n - 1])

Python: while True:
    n,r = map(int,input().split())
    if n == 0:
        break
    card = []
    for i in range(n):
        card.append(n - i)
    for i in range(r):
        p,c = map(int,input().split())
        card = card[p - 1:p + c - 1] + card[0:p - 1] + card[p + c - 1:n]
    print(card[0])

Python: while True:
  n,r = tuple(map(int,input().split()))
  if n==0 and r==0:
    break
  l = [n-i for i in range(n)]
  for i in range(r):
    p,c = tuple(map(int,input().split()))
    l1 = [l[i] for i in range(p-1,p+c-1)]
    l2 = [l[i] for i in range(0,p-1)]
    l3 = l1+l2
    for i in range(p+c-1):
      l[i] = l3[i]
  print(l[0])

Python: while 1:
    n, r=map(int, input().split())
    if n==0:
        break
    a=[n-i for i in range(n)]
    for _ in range(r):
        p, c=map(int, input().split())
        a=a[p-1:p-1+c] + a[0:p-1] + a[p-1+c:]
    print(a[0])

Python: first = input().split()
n = int(first[0])
r = int(first[1])
while n != 0 or r != 0:
    i = 0
    card = list(range(1,n+1))[::-1]
    while i < r:
        sh = input().split()
        p, c = list(map(int,sh))
        card = card[p-1:p+c-1] + card[:p-1] + card[p+c-1:]
        i = i + 1
    print(card)
    next = input().split()
    n, r = list(map(int,next))

Python: def main(n, m):
    dp = [(i + 1) for i in range(n)]
    dp = dp[::-1]
    for _ in range(m):
        p, c = map(int, input().split())
        dp = dp[p - 1:p + c - 1] + dp[:p - 1] + dp[p + c - 1:]
    print(dp[0])
while 1:
    n, r = map(int, input().split())
    if n == r == 0:
        break
    main(n,r)