Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	for sc.Scan() {
		if sc.Text() == "0 0" {
			break
		}
		chunks := strings.Split(sc.Text(), " ")
		n, _ := strconv.Atoi(chunks[0])
		r, _ := strconv.Atoi(chunks[1])
		cards := make([]int, n, n)
		for i := 0; i < n; i++ {
			cards[i] = n - i
		}
		for i := 0; i < r; i++ {
			sc.Scan()
			chunks := strings.Split(sc.Text(), " ")
			p, _ := strconv.Atoi(chunks[0])
			c, _ := strconv.Atoi(chunks[1])
			block := make([]int, c, c)
			for j := 0; j < c; j++ {
				block[j] = cards[p+j-1]
			}
			for j := p - 2; j >= 0; j-- {
				cards[j+c] = cards[j]
			}
			for j := 0; j < c; j++ {
				cards[j] = block[j]
			}
		}
		fmt.Println(cards[0])
	}
}

Python: while True:
    n, r = map(int, input().split())
    if n == 0:
        break
    else:
        cards = list(reversed(range(n)))
        for _ in range(r):
            p, c = map(int, input().split())
            for i,x in enumerate(cards):
                if 0 <= x < p-1:
                    cards[i] += c
                elif p-1 <= x < p-1+c:
                    cards[i] -= p-1
                else:
                    pass
        for i,x in enumerate(cards):
            if x == 0:
                print(i+1)

Python: 
while True:
	n, r = map(int, input().split())
	if (n, r) == (0, 0):
		break
	cards = list(range(1, n+1))[::-1]
	print(cards)

	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 True:
    n,r = map(int,input().split())
    if n==r==0: break
    l = list(range(n,0,-1))
    for i in range(r):
        p,c = map(int,input().split())
        l = l[p-1:p+c-1]+l[:p-1]+l[p+c-1:]
    print(l[0])

Python: import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline()[:-1]
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(0, 1), (1, 0), (0, -1), (-1, 0)]

def main():
    while 1:
        n,r=MI()
        if n==0:break
        aa=list(range(n,0,-1))
        for _ in range(r):
            p,c=MI()
            aa=aa[p-1:p-1+c]+aa[:p-1]+aa[p-1+c:]
        print(aa[0])

main()

Python: while True:
    n, r = map(int, input().split())
    if n == 0 and r == 0:
        break
    deck = [i + 1 for i in range(n)]
    for shuffle in range(r):
        p, c = map(int, input().split())
        # print("start: {}, end: {}".format(len(deck) - p - c + 1, len(deck) - p + 1))
        hoge = deck[len(deck) - p - c + 1 : len(deck) - p + 1]
        del deck[len(deck) - p - c + 1 : len(deck) - p + 1]
        deck.extend(hoge)
        # print("現在の山札: {}".format(deck))
    print(deck[-1])

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

    card = list(range(n, 0, -1))
    for _ in range(r):
        p, c = map(int, input().split())
        tmp = card[p-1:p-1+c]
        del card[p-1:p-1+c]
        card[0:0] = tmp

    print(card[0])

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

    ope = [list(map(int, input().split())) for _ in range(r)]
    d = [n-i for i in range(n)]

    for i in range(r):
        tv = d[ope[i][0]-1:ope[i][0]-1+ope[i][1]]
        to = d[:ope[i][0]-1] + d[ope[i][0]-1+ope[i][1]:]
        d = tv + to
    print(d[0])

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

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

    deck = [n - i for i in range(n)]
    for i in range(r):
        p, c = map(int, input().split())
        deck = deck[p - 1 : p + c - 1] + deck[:p - 1] + deck[p + c - 1:]
    print(deck[0])

Python: #! /usr/bin/python3

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

Python: #!/usr/bin/env python
# -*- coding: utf-8 -*-
import heapq

while True:
    n,r = map(int,input().split(" "))
    if n==0 and r == 0:
        break
    q = []
    for i in range(n):
        heapq.heappush(q,(i,n-i))
    for i in range(r):
        p,c = map(int,input().split(" "))
        tmpQueue = []
        for j in range(p-1+c):
            tp = heapq.heappop(q)
            if j < p-1:
                heapq.heappush(tmpQueue,(j+c,tp[1]))
            else:
                heapq.heappush(tmpQueue,(j-p+1,tp[1]))
        for j in range(p-1+c):
            heapq.heappush(q,heapq.heappop(tmpQueue))
    print(heapq.heappop(q)[1])

Python: def shuffle(arr, p, c):
    p -= 1
    cut = arr[p: p + c]
    top = arr[:p]
    bot = arr[p + c:]
    return cut + top + bot

if __name__ == '__main__':
    while True:
        N, R = list(map(int, input().split()))
        if N == 0 and R == 0:
            break

        arr = [ N - x for x in range(N) ]

        for _ in range(R):
            p, c = list(map(int, input().split()))
            arr = shuffle(arr, p, c)
        
        print(arr[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-1+c:]

    print(cards[0])

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

while n!=0 and r!=0:
	card = list(range(1,n+1))[::-1]
	for _ in range(r):
		p,c = map(int,input().split())
		pcard = card[0:p-1]
		ccard = card[p-1:p-1+c]
		tmp = card[p-1+c:]
		nxt = []
		nxt.extend(ccard)
		nxt.extend(pcard)
		nxt.extend(tmp)
		card = nxt
	print(card[0])
	n,r = map(int,input().split())

Python: n,r=map(int,input().split())
while n!=0 or r!=0:
    card=[i for i in range(n,0,-1)]
    for i in range(r):
        p,c=map(int,input().split())
        for j in range(c):
            card.insert(0,card.pop(c+p-2))
    print(card[0])
    n,r=map(int,input().split())

Python: while True:
    a=[int(num)for num in input().split(' ')]
    n=a[0]
    if n==0:break
    hanafuda=[i+1 for i in range(n)]
    for i in range(a[1]):
        b=[int(num)for num in input().split(' ')]
        for j in range(b[1]):hanafuda.append(hanafuda.pop(n-(b[0]+b[1])+1))
    print(hanafuda.pop())

Python: def main():
    ans = []
    while True:
        n, r = map(int, input().split())
        if n == 0 and r == 0:
            break
        cards = []
        for i in range(n):
            cards.append(i+1)
        cards = cards[::-1]
        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:]
        ans.append(cards[0])

    for i in range(len(ans)):
        print(ans[i])

main()

Python: while True:
    n,r=[int(s)for s in input().split(" ")]
    if n==r==0:break
    ops=[[int(s)for s in input().split(" ")]for i in range(r)]
    cd=[n-i for i in range(n)]
    for op in ops:
        p,c=op
        l=cd[p-1:p+c-1]
        del cd[p-1:p+c-1]
        cd=l+cd
    print(cd[0])