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 <iostream>
#include <algorithm>

using namespace std;

int main(){
	int n,r;
	while(cin >> n >> r,n){
		int s[n];
		for(int i=0;i<n;i++){
			s[i] = n-i;
		}
		for(int i=0;i<r;i++){
			int p,c;
			cin >> p >> c;
			rotate(s,s+p-1,s+p+c-1);
		}
		cout << s[0] << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){

  while(1){
    int n,r;
    cin>>n >>r;
    if(n==0&&r==0)  break;
    int cards[n-1];
    REP(i,n){
      cards[i] = (n-i);
    }
    int help[100]={0};
    int p[100];
    int c[100];
    REP(i,r){
      cin>>p[i]>>c[i];
      REP(j,(c[i]-1)){
	help[j]=cards[(p[i]+j)];
      }
      REP(j,(c[i]-1)){
	cards[p[i]+c[i]-j]=cards[p[i]-j];
      }
      REP(j,(c[i]-1)){
	cards[c[i]-j-1]=help[c[i]-j-1];
      }
    }
    cout << cards[0] << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a ; i<b ; i++)
#define dump(x) cout << #x << " = " << x << endl

using namespace std;

int card[50];
int n, r;

void disp(){
	rep(i,0,n) cout << card[i] << " ";
	cout << endl;
	return ;
}

int main(){

	while(1){
		cin >> n >> r;
		if(n==0) break;

		rep(i,0,n) card[i] = n - i;
		// disp();

		rep(i,0,r){
			int p, c;
			cin >> p >> c;
			int temp[p];

			rep(i,0,p-1) temp[i] = card[i];
			rep(i,0,c) card[i] = card[p-1+i];
			rep(i,0,p-1) card[c+i] = temp[i];

			// disp();

		}

		cout << card[0] << endl;

	}
	return 0;
}

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

int main(){
	int n,r;
	while((cin >> n)&&(cin >> r)&&(n!=0)&&(r!=0)){
		int a[256];
		int cnt=n;
		for(int i=0;i<n;i++){
			a[i] = cnt;
			cnt--;
			//cout << "a[" << i << "]" << a[i] << endl;
		}
		int p,c;
		//cout << endl;
		for(int i=0;i<r;i++){
			cin >> p;
			cin >> c;
			int b[50];
			//cout << p << endl;
			//cout << c << endl;
			//cout << endl;
			if(n!=c){
				for(int j=0;j<p;j++){
					b[j+c] = a[j];
				}
				for(int j=0;j<c;j++){
					b[j] = a[p+j-1];	
				}
				for(int j=0;j<p+c;j++){
					a[j] = b[j];	
					//cout << "a[" << j << "]" << a[j] << endl;
				//	cout << "b[" << j << "]" << b[j] << endl;
				}
			}
		}
		cout << a[0] << endl;
	}
}

C++: #include <iostream>
#include <string>

using namespace std;
 
 
int n, r, p, c;
int card[51], tmp[51];
 
int main(){
    while(cin >> n >> r, n){
        if(n == 0 && r == 0) break;
        for(int i = 0; i < n; i++) card[i] = n-i;
        for(int i = 0; i < r; i++){
            cin >> p >> c;
            p--;
            for(int j = p; j < p+c; j++) tmp[j-p] = card[j];
            for(int j = p-1; j >= 0; j--) card[j+c] = card[j];
            for(int j = 0; j < c; j++) card[j] = tmp[j];
        }
        cout << card[0] << endl;
    }
}

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

int main(){
	int n,r;
	int c= 0;
	while((cin >> n)&&(cin >> r)&&(n!=0)&&(r!=0)){
		int a[n];
		int cnt=n;
		for(int i=0;i<n;i++){
			a[i] = cnt;
			cnt--;
			//cout << "a[" << i << "]" << a[i] << endl;
		}
		int p,c;
		//cout << endl;
		for(int i=0;i<r;i++){
			cin >> p;
			cin >> c;
			int b[p+c];
			//cout << p << endl;
			//cout << c << endl;
			//cout << endl;
			if(n!=c){
				for(int j=0;j<p;j++){
					b[j+c] = a[j];
				}
				for(int j=0;j<c;j++){
					b[j] = a[p+j-1];	
				}
				for(int j=0;j<p+c;j++){
					a[j] = b[j];	
					//cout << "a[" << j << "]" << a[j] << endl;
				//	cout << "b[" << j << "]" << b[j] << endl;
				}
			}
		}
		cout << a[0] << endl;
	}
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<long long,int> P;
static const int INF=1<<24;

int a[50];

int main(){
	int n,r;
	while(cin>>n>>r,!(n==0&&r==0)){
		rep(i,n+1){
			a[i]=n-i;
		}
		int p,c;
		int t1[50]={0},t2[50]={0};
		
		rep(i,r){
			cin>>p>>c;
			for(int j=0;j<c;j++){
				t1[j]=a[j+p-1];
				//cout<<t1[j]<<endl;
			}
			//cout<<endl;
			for(int j=0;j<p-1;j++){
				t2[j]=a[j];
			}
			for(int j=0;j<c;j++){
				a[j]=t1[j];
			}
			for(int j=0;j<p-1;j++){
				a[j+c]=t2[j];
			}
			/*
			rep(j,n){
				cout<<a[j]<<" ";
			}
			cout<<endl;
			*/
		}
		cout<<a[0]<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)

int main(){
	while(1){
		int n,r;
		cin>>n>>r;
		if(n==0&&r==0) break;
		int a[50],b[50];
		lp(i,50){
			a[i]=i+1;
			b[i]=-1;
		}
		lp(i,r){
			int p,c;
			cin>>p>>c;
			lp(j,p){
				b[n-p-c+1+j]=a[n-p+1+j];
			}
			lp(j,c){
				b[n-c+j]=a[n-p-c+1+j];
			}
			lp(j,n){
				if(b[j]!=-1){
					a[j]=b[j];
				}
			}
			lp(j,50){
				b[j]=-1;
			}
		}
		cout<<a[n-1]<<endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int x[100];
int y[100];
int card [100];
int n,r;
bool input(){
	for(int i=0;i<100;i++){
	x[i]=0;
	y[i]=0;
	}
	cin >>n>>r;
	for(int i=0;i<r;i++){
	cin>>x[i]>>y[i];
	}
	if(n==0){
	return false;
	}
	else{
	 return true;
	}
}
void solve(){
	for(int i=0;i<100;i++){
		card[i]=i+1;
	}
	for(int i=0;i<r;i++){
		for(int k=0;k<y[i];k++){
			int a=card[x[i]+y[i]-2];
			for(int j=x[i]+y[i]-1;j>0;j--){
				card[j]=card[j-1];
			}
			card[0]=a;
		}
	}
	cout<<n-card[0]+1<<endl;
}



int main (){
	while(input()){
	solve();
	}
return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for (int i=(n)-1;i>=0;i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define REPS(i,f,n) for (int i=(f)-1;i>=(n);i--)
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};

void slove(int n, int r){//n ???????????° r ??????????????°
	stack<int> s;
	rep(i, n) s.push(i);//?????????

	rep(i, r){//r????????????
		int p, c;
		cin >> p >> c;
		stack<int> tmp1;
		stack<int> tmp2;
		rep(i, p - 1){
			tmp1.push(s.top());
			s.pop();
		}
		rep(i, c){
			tmp2.push(s.top());
			s.pop();
		}

		rep(i, c){
			s.push(tmp2.top());
			tmp2.pop();
		}
		rep(i, p - 1){
			s.push(tmp1.top());
			tmp1.pop();
		}
	}

	printf("%d\n", s.top());
	return;
}

int main(void){
	int n, r;
	cin >> n >> r;
	while(n != 0 || r != 0){
		slove(n, r);
		cin >> n >> r;
	}
	return 0;
}