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: #-*- coding: utf-8 -*-
def hanafuda(a, p, c):
    for i in range(0,c):
        b = []
        b.append(a.pop(p+i-1))
        for j in range(0, len(b)):
            a.insert(0, b.pop(j))
    return a[0]

while(1):
    n, r = (int(i) for i in input().split())
    if (n == 0 and r == 0):
        exit(0)
    else:
        a = [int(i) for i in range(1,n+1)]
        a.reverse()
        for i in range(r):
            p, c = (int(i) for i in input().split())
            c =  hanafuda(a, p, c)
        print(c)

Python: ans = []
while True:
    n,r = map(int,input().split())
    if n == 0 and r == 0:
        break
    x = [i for i in range(1,n+1)]
    for i in range(r):
        p,c = map(int,input().split())
        x = x[:n-(p-1+c)] + x[n-(p-1):] + x[n-(p-1+c):n-(p-1)]
    ans.append(x[-1])
print("\n".join(map(str,ans)))

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

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:p-1+c] + cards[:p-1] + cards[p-1+c:]
    print(cards[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))
    
    if n ==0 and r==0:
        break

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

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

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

Python: from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

while True:
    n,r = inpl()
    if n == 0:
        break
    else:
        yama = [n-i for i in range(n)]
        for _ in range(r):
            p,c = inpl()
            next_yama = yama[p-1:p-1+c] + yama[:p-1] + yama[p-1+c:]
            yama = next_yama
        print(yama[0])

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

Python: 
while True:
	n, r = map(int, input().split())
	if (n, r) == (0, 0):
		break
	cards = list(range(1, n+1))[::-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:]
	print(cards[0])

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

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

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

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

Python: #!/usr/bin/env python3

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

Python: while True:
    n, r = [int(s) for s in input().strip().split()]

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

    cards = list(range(1, n+1))
    cards.reverse()

    for _ in range(r):
        p, c = [int(s) for s in input().strip().split()]

        part1 = cards[0:p-1]
        part2 = cards[p-1:p-1+c]

        cards[0:c] = part2
        cards[c:c+p-1] = part1

    print(cards[0])

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

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

Python: 
def shuffle(cards):
    index,cut_num = map(int,input().split()) 
    pop = cards[index-1 :index + cut_num-1 ]
    del cards[index-1:index + cut_num-1]
    return pop + cards 

while True:
  num_card,challange = map(int,input().split()) 
  if num_card == 0 and challange == 0:
      break

  cards = list(reversed(range(1,num_card+1)))
  for i in range(challange):
      cards = shuffle(cards)
  print(cards[0])

Python: while True:
    N, R = map(int, input().split())
    if N == 0 and R == 0:
        break
    L = [i for i in range(N, 0, -1)]
    for i in range(R):
        p, c = map(int, input().split())
        p -= 1
        c = p + c
        tmp = L[p:c]
        tmp.extend(L[:p])
        tmp.extend(L[c:])
        L = tmp[:]
    print(L[0])