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 <iostream>
#include <algorithm>
using namespace std;

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

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