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

C++: #include "bits/stdc++.h"

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

    int n,r;
    while(cin>>n>>r,n&&r){
        vector<int> old_cards(n),new_cards(n);
        for(int i=0;i<n;i++) old_cards[i]=n-i;
        for(int j=0;j<r;j++){
            int p,c;cin>>p>>c;
            for(int i=0;i<c;i++) new_cards[i]=old_cards[p-1+i];
            for(int i=c;i<p-1+c;i++) new_cards[i]=old_cards[i-c];
            for(int i=p-1+c;i<n;i++) new_cards[i]=old_cards[i];

            for(int i=0;i<n;i++) old_cards[i]=new_cards[i];
        }
        cout<<old_cards[0]<<endl;
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


void f(int n,int r){
  int a[100];
  rep(i,n){
    a[i+1]=n-i;
  }

  rep(i,r){
    int p,c;
    cin>>p>>c;
    int b[100];
    rep(j,p-1){
      b[j]=a[j+1];
    }
    rep(j,c){
      a[j+1]=a[p+j];
    }
    rep(j,p-1){
      a[j+c+1]=b[j];
    }
  
    
  }

  cout<<a[1]<<endl;

}

int main(){
  while(1){
    int n,r;
    cin>>n>>r;
    if(n==0) break;
    f(n,r);
  }

  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
int main(void){
    int n,r;
    while(cin>>n>>r,n){
        list<int> deck(n);
        iota(rall(deck),1);
        rep(i,r){
            int p,c;
            cin>>p>>c;
            auto itr=deck.begin();
            rep(j,p+c-2) itr++;
            rep(j,c){
                deck.push_front(*itr);
                itr=deck.erase(itr);
                itr--;
            }
        }
        cout<<deck.front()<<endl;
    }
}

C++: #include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n, r, p, c;
	vector<int> v;
	while(scanf("%d%d", &n, &r), n){
		v.resize(n);
		for(int i = 0; i < n; ++i){
			v[i] = n - i;
		}

		for(int i = 0; i < r; ++i){
			scanf("%d%d", &p, &c);
			--p;
			rotate(v.begin(), v.begin() + p, v.begin() + (p + c));
		}
		printf("%d\n", v[0]);
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int solve(int n,int r){
    vector<pair<int,int> >p;
    for(int i=0;i<r;i++){
        int a,b;
        cin >> a >> b;
        p.push_back(make_pair(a,b));
    }

    reverse(p.begin(),p.end());
    int x = n;
    for(vector<pair<int,int> >::iterator it=p.begin();
        it != p.end();
        ++it){
        int a = (*it).first;
        int b = (*it).second;
        if(x >= (n-b+1)){
            x = x - (a-1);
        }else if(x >= (n-b)-(a-1)){
            x = x + b;
        }
    }
    cout << x << endl;
}

int main(){
    int n,r;
    while(cin >> n >> r){
        if(n==0 && r==0){
            break;
        }
        solve(n,r);
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
    int N,r;
    vector<int> ans;
    while(cin>>N>>r,N != 0 && r != 0){

        queue<int> card;
        for(int i = 1;i <= N;i++) card.push(i);

        for(int i=0;i<r;i++){
            int P,C;
            queue<int> p;
            queue<int> c;
            cin>>P>>C;
            
            for(int i=0;i<P;i++){
                p.push(card.front());
                card.pop();
            }

            for(int i=0;i<C;i++){
                c.push(card.front());
                card.pop();
            }

            while(!p.empty()){
                card.push(p.front());
                p.pop();
            }

            while(!c.empty()){
                card.push(c.front());
                c.pop();
            }
            
        }
        ans.push_back(card.front());
    }
    for(int i : ans) cout<<i<<endl;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;

int main() {
int N,R,p,c;
while (cin>>N>>R&&N) { 
	int A[100]={};
	for(int i=0;i<N;i++){
		A[i]=i+1;
	}
	reverse(A,A+N);
	for (int i=0; i<R; ++i) {
	cin >> p >> c ;
	rotate(A,A+p-1,A+p+c-1);

 }
 cout << A[0] << endl;
 }
	return 0;
}

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

C++: #include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;
int n,r;
int p,c;
vector<int> card;
vector<int> tmp;
int main(){
  while(true){

    cin >> n >> r;
    if(n==0&&r==0)break;
    card.resize(n+2);
    REP(i,n)card[i]=i+1;
    REP(i,r){
      cin >> p >> c;
      for(int j=n-p+1;j<n;j++){
	tmp.push_back(card[j-c]);
	card[j-c] = card[j];
      }
	if(p!=1)
	  for(int j=n-c;j<n;j++)
	    card[j] =tmp[j-n+c];
      tmp.clear();
    }
    cout << card[n-1] << endl;
    card.clear();

  }

  return 0;
    
}