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

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