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

Python: temp = True
i = 0
N = []
M = []
while True:
    p,c = map(int, input().strip().split(' '))
    if p == 0 and c == 0:
        break
    if temp:
        n = p
        r = c
        for j in range(n):
            N.append(n-j)
        temp = False
    else:
        for j in range(c):
            M.append(N[p+j-1])
        for j in range(p-1):
            M.append(N[j])
        for j in range(n-c-p+1):
            M.append(N[j+c+p-1])
        N = M
        M = []
        i = i + 1
        if i == r:
            print(N[0])
            temp = True
            N = []
            i = 0

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

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

while True:
    case = []
    cards = [n for n in range(1,cond[0] + 1)]
    cards.sort(reverse = True)
    for c in range(cond[1]):
        case = [int(n) for n in input().split(" ")]
        case[0] -= 1
        #print(cards[case[0]:case[0]+case[1]],cards[case[1]:case[0]+case[1]],cards[:case[1]],cards[:case[1]])
        disp = cards[case[0]:case[0]+case[1]]
        cards[case[1]:case[0]+case[1]] = cards[0:case[0]]
        cards[0:case[1]] = 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: while True :
  n, r = map(int, input().split())
  if(n == 0 and r == 0) :
    break
  else :
    card = list()
    for i in range(n) :
      card.append(i + 1)
    card = card[::-1]
    for i in range(r) :
      p, c = map(int, input().split())
      card = card[p-1:p+c-1] + card[:p-1] + card[p + c - 1:]
      # スライス
    print(card[0])

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

Python: first = input().split()
n = int(first[0])
r = int(first[1])
while n != 0 or r != 0:
    i = 0
    card = list(range(n))
    while i < r:
        sh = input().split()
        p, c = list(map(int,sh))
        card = card[p-1:p+c-2:] + card[0:p-2:] + card[p+c-1:n:]
        i = i + 1
    print(n - int(card[0]))
    next = input().split()
    n, r = list(map(int,next))

Python: while True:
    amount, count = map(int, input().split())
    if amount == 0 and count == 0:
        break

    cards = [i for i in reversed(range(1, amount + 1))]

    for _ in range(count):
        p_th, length = map(int, input().split())
        swapper = cards[p_th - 1:p_th + length - 1]
        cards[p_th - 1:p_th + length - 1] = []
        cards[0:0] = swapper

    print(cards[0])

Python: #!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array


def operation(p, c, cards):
    return cards[p - 1: p + c - 1] + cards[:p - 1] + cards[p + c - 1:]


if __name__ == "__main__":
    while True:
        n, r = map(int, input().split())
        if n == 0 and r == 0:
            break
        else:
            cards = array.array("B", range(n, 0, -1))
            for i in range(r):
                p, c = map(int, input().split())
                cards = operation(p, c, cards)
            print(cards[0])

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

Python: # Hanafuda Shuffle

ans = []

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

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

for i in ans:
    print(i)

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


if __name__=="__main__":
	main()

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

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