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: #hanafuda
N,r=(int(i) for i in input().split())
H=[int(i) for i in range(N)]
for i in range(N):
    p,c=(int(i) for i in input().split())
    T=[]
    for j in range(p,p+c-1):
        T.append(H[p])
        H.pop(p)
    H=T+H
print(H[0])

Python: while True:
    n, r = map(int, input().split())

    if n == 0 and r == 0:
        break

    cards = list(range(1, n+1))[::-1]

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

    print(cards[0])

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):
        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: if __name__ == "__main__":
    while True:
        n,r=list(map(int,input().strip().split()))
        if n == 0 and r ==0 :break
        cards = [i for i in range(1,n + 1)]
        pset = []
        cset = []
        for j in range(r):
            p,c = list(map(int,input().strip().split()))
            pset = cards[n-(p - 1):]
            cset = cards[n-c-(p-1):n-(p-1)]
            other = cards[:n-c-(p-1)]
            cards = other + pset + cset
        print(cards[n-1])

Python: # encoding: utf-8
def create_deck(deck_size):
    deck = []
    for i in range(0,deck_size):
        deck.append(i+1)
    return deck

def shuffle_deck(deck, start, cut_size):
    after = []
    cut_cards = []
    b = len(deck) - cut_size - start
    for i in range(0,len(deck)):
        if b >= i:
            after.append(deck[i])
            continue
        if (b+cut_size) >= i:
            cut_cards.append(deck[i])
            continue
        after.append(deck[i])
    after.extend(cut_cards)
    return after

while True:
    data = input().split()
    deck_size, shuffle_count = int(data[0]),int(data[1])
    if deck_size == shuffle_count == 0: break
    deck = create_deck(deck_size)
    for i in range(0,shuffle_count):
        cut_info = data = input().split()
        start, cut_size = int(cut_info[0]),int(cut_info[1])
        deck = shuffle_deck(deck, start, cut_size)
    print(deck[len(deck)-1])

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

Python: while True:
	sousa=input().split()
	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().split()
		[p,c]=[int(p),int(c)]
		yama[:p+c-1]=yama[p-1:p+c-1]+yama[:p-1]
	print(yama[0])

Python: while (True):
    n, r = map(lambda i: int(i), input().split())
    if n == 0:
        break

    inds = [i for i in reversed(range(1, n+1))]

    for i in range(r):
        p, c = map(lambda j: int(j), input().split())
        inds = inds[p-1:p-1+c] + inds[:p-1] + inds[p-1+c:]

    print(inds[0])

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

Python: # -*- coding: utf-8 -*-

def main():
    while 1:
        n, r = list(map(int,input().split()))
        l = list(range(n, 0, -1))
        if n == 0 and r == 0:
            return 0
        for _ in range(r):
            p, c = list(map(int, input().split()))
            l_ = l[p-1:p+c-1]
            l_.extend(l[:p-1])
            l_.extend(l[p+c-1:])
            l = l_
        print(l[0])


if __name__ == "__main__":
    main()

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

Python: import copy 
def solve():
  while(True):
    n, r = map(int, input().split())
    beforelist = [i for i in range(n, 0, -1)]
    afterlist = copy.deepcopy(beforelist)
    #print(beforelist)
    #print(afterlist)
    if n == 0 and r == 0:
        break
    for _ in range(r):
        p, c = map(int, input().split())
        j = 0
        for i in range(p-1,p-1+c):
            #print(beforelist)
            afterlist[j] = copy.deepcopy(beforelist[i])
            j+=1
            #print(afterlist)
            #print(beforelist)
        for i in range(0,p-1):
            afterlist[j] = copy.deepcopy(beforelist[i])
            j+=1
        beforelist = copy.deepcopy(afterlist)
        #print(afterlist)
    print(beforelist[0])
if __name__ == '__main__':
  solve()

Python: while True:
	l = input()
	L = l.split()
	for i in range(len(L)):
		L[i] = int(L[i])
	if L[0] == 0:
		break	
	a = [L[0]-number for number in range(L[0])]
	for j in range(L[1]):
		r = input()
		R = r.split()
		for k in range(len(R)):
			R[k] = int(R[k])
		b = []
		b += a[R[0]-1:R[0]+R[1]-1]
		b += a[:R[0]-1]
		b += a[R[0]+R[1]-1:]
		a.clear()
		a = b.copy()
	print(a[0])

Python: n=1
r=1
while n !=0 and r!=0:
    n,r=input().split()
    n,r=int(n),int(r)

    card= [[int(i) for i in input().split()] for i in range(r)]
    yama= list(range(n,0,-1))
 

    for i in range(r):
        p=card[i][0]
        c=card[i][1]
        x=yama[:p-1]
        y=yama[p-1:p-1+c]
        z=yama[p-1+c:] 
      
       
        yama=(y+x+z)
        print(yama[0])

Python: n=1
r=1
while n !=0 and r!=0:
    n,r=input().split()
    n,r=int(n),int(r)

    card= [[int(i) for i in input().split()] for i in range(r)]
    yama= list(range(n,0,-1))
 

    for i in range(r):
        p=card[i][0]
        c=card[i][1]
        x=yama[:p-1]
        y=yama[p-1:p-1+c]
        z=yama[p-1+c:] 
      
       
        yama=(y+x+z)
        
    print(yama[0])

Python: ans_list = []

while True:
    n,r = map(int,input().split())
    if (n,r) == (0,0):
        break
    pc = [list(map(int,input().split())) for _ in range(r)]
    mt = list(range(1,n+1)[::-1])

    def cal(p,c):
        global mt
        mt = mt[p-1:p-1+c] + mt[:p-1] + mt[p-1+c:]
    
    for p,c in pc:
        cal(p,c)
    
    ans = mt[0]
    ans_list.append(ans)

for ans in ans_list:
    print(ans)

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