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

C++: #include <cctype>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define LL long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
	int n, r;

	while(cin >> n >> r, n + r){
		int huda[51];
		REP(i, n){
			huda[i] = n - i;
		}
		
		while(r--){
			int p, c;
			int tmp[c];
			cin >> p >> c;
			
			REP(i, c){
				tmp[i] = huda[p + i - 1];
			}
			
			REPR(i, p - 2){
				huda[i + c] = huda[i];
			}

			REP(i, c){
				huda[i] = tmp[i];
			}
		}

		cout << huda[0] << endl;
	}
}

C++: //#define _GRIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int n, r;
    while(cin>>n>>r, n) {
        vi v(n);
        rep(i,n) v[i] = n-i;
        rep(i,r) {
            vi tmp = v;
            int p, c;
            cin >> p >> c;
            rep(j,p-1) tmp[j+c] = v[j];
            rep(j,c) {
                tmp[j] = v[j+p-1];
            }
            swap(tmp,v);
        }
        P(v[0]);
    }
    return 0;
}

C++: #include <bits/stdc++.h>

int n = 0;

void display(int *arr){
  for(int i = 0; i < n; i++){
    std::cout << arr[i] << " ";
  }
  std::cout << std::endl;
}

int main(){

  /*std::vector<int> tmp;
  for(int i = 0; i < 10; i++){
    tmp.push_back(i);
    std::cout << tmp[i] << " ";
  }
  std::cout << std::endl;

  tmp.erase(tmp.end() - 6, tmp.end() - 3);
  for(int i = 0; i < tmp.size(); i++){
    std::cout << tmp[i] << " ";
  }

  std::cout << std::endl;*/
  
  while(1){
    int r;
    std::cin >> n >> r;    
    if(n + r == 0) break;
    std::vector<int> yama;
    for(int i = 0; i < n; i++){
      yama.push_back(i);
      //std::cout << yama[i] << " ";
    }
    //std::cout << std::endl;

    for(int i = 0; i < r; i++){
      int p, c;
      std::cin >> p >> c;
      std::vector<int> tmp;
      //std::cout << n << " " << r << " " << p << " " << c << std::endl;
      for(int j = 0; j < c; j++){
        tmp.push_back(yama[n - p - c + 1 + j]);
        //std::cout << tmp[j] << std::endl;
      }
      yama.erase(yama.end() - (p - 1 + c), yama.end() - (p - 1));
      //display(yama.data());
      for(int j = 0; j < tmp.size(); j++){
        yama.push_back(tmp[j]);
      }
    }
    std::cout << yama[yama.size() - 1] + 1 << std::endl;
    
  }

  return 0;
  
}

C++: #include <cstdio>
 
using namespace std;
 
int n, r;
int cards[2][51];
 
int main() {
  while (true) {
    scanf("%d %d", &n, &r);
    if (n == 0 && r == 0) break;
    for (int i=0;i<n;i++) cards[0][i] = n-i;
    for (int i=0;i<r;i++) {
      int p, c;
      scanf("%d %d", &p, &c);
      for (int j=0;j<c;j++) {
        cards[(i+1)&1][j] = cards[i&1][p-1+j];
      }
      for (int j=0;j<p-1;j++) {
        cards[(i+1)&1][c+j] = cards[i&1][j];
      }
      for (int j=p-1+c;j<n;j++) {
        cards[(i+1)&1][j] = cards[i&1][j];
      }
    }
    printf("%d\n", cards[r&1][0]);
  }
}

C++: #include <bits/stdc++.h>

using namespace std;

int n[10000]={},r[10000]={};
int p[10000][50] = {};
int c[10000][50] = {};
int i=0;

int d[50]={};
int e[50] = {}; //今の状態
int e2[50] = {};

int main(){
    while(1){
        scanf("%d %d",&n[i],&r[i]);
        if(n[i]== 0 && r[i]== 0){
            break;
        }
        for(int j=0;j<r[i];j++){
            scanf("%d %d",&p[i][j],&c[i][j]);
        }
        i++;
    }
    int times = i;
    for(i=0;i<times;i++){
        //初期化
        int s=0;
        for(int k = n[i]; k>0;k--){
            e[s] = k;
            s++;
        }
        for(int j=0;j<r[i];j++){
            s=0;
            for(int t=p[i][j]-1;t<p[i][j]+c[i][j]-1;t++){
                d[s] = e[t];
                s++;
            }
            for(int t = 0;t < n[i];t++){
                e2[t] = e[t];
            }
            for(int t = 0;t<c[i][j];t++){
                e[t] = d[t];
            }
            s = 0;
            for(int t=c[i][j];t<p[i][j]+c[i][j]-1;t++){
                e[t] = e2[s];
                s++;
            }


        }
        
        cout << e[0] << endl;
    }

    return 0;
}

C++: #include <iostream>
using namespace std;
int main( void )
{
  while( 1 ){
    int n,r,p,c;
    int d[2][55];
    cin >> n >> r;
    if( n == 0 ) break;
    for( int i=0; i<n; i++ ){
      d[0][i] = n-i;
    }
    for( int i=0; i<r; i++ ){
      cin >> p >> c;
      int k = i & 1;
      for( int j=0; j<c; j++ ){
        d[1-k][j] = d[k][j+p-1];
      }
      for( int j=0; j<p-1; j++ ){
        d[1-k][j+c] = d[k][j];
      }
      for( int j=c+p-1; j<n; j++ ){
        d[1-k][j] = d[k][j];
      }
    }
    cout << d[r&1][0] << endl;
  }
}