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

Python: def solve(n, r, pc):
    deck = [n+1-i for i in range(1,n+1)]
    for p, c in pc:
        deck = deck[p-1:p+c-1] + deck[0:p-1] + deck[p+c-1:]
    return deck[0]

def main():
    ans = []
    while True:
        n, r = map(int, input().split())
        if (n==0) and (r==0):
            break
        pc = [list(map(int, input().split())) for i in range(r)]
        ans.append(solve(n, r, pc))
    
    for i in ans:
        print(i)
    
main()

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])