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++: #define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int A[101];
int B[101];
int C[101];

int main()
{
	int n, r; 
	while(1) {
		cin >> n >> r;
		if (!n && !r) break;
		rep(i,0,n) A[i] = n-i;
		rep(i,0,r) {
			int t, c; cin >> t >> c;
			t--;
			// ??????
			rep(j,0,t) B[j] = A[j];
			rep(j,t,t+c) C[j-t] = A[j];
			// ??????
			rep(j,0,c) A[j] = C[j];
			rep(j,c,c+t) A[j] = B[j-c];
		}
		cout << A[0] << endl;
	}

 	return 0;
}

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

int n,r,p,c;

int main(){
  while(cin >> n >> r && n!=0 || r!=0){
    int A[n];
    for(int i=0;i<n;i++){
      A[i]=n-i;
    }
    //for (auto e:A) cout << e;
    //cout << "\n";
    for(int i=0;i<r;i++){
      cin >> p >> c;
      rotate(A,A+p-1,A+p-1+c);
    }
    cout << A[0] << endl;
  }
}

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

int N,R,p,c;
int main() {
  while (cin >> N >> R && N) {
  array<int,50> A = {};
  for (int i=0;i<N;i++) {
    A[i] = N-i;
  }
  /*  for (int i=0;i<N;i++) {
    cout << A[i];
  }
  cout << endl; */
  for (int i=0;i<R;i++) {
    cin >> p >> c;
    rotate(A.begin(),A.begin()+p-1,A.begin()+p-1+c);
    /*    for (int i=0;i<N;i++) {
      cout << A[i];
    }
    cout << endl; */
  }
  cout << A[0] << endl;
}
}

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

int main(){

while(cin >> N){
  if(N == 0) break;
  
  int A[N];
  for (int i = 0; i < N; ++i){
    A[i] = i+1; 
  }
  reverse(A,A+N);

  int r = 0; 
  cin >> r; 
  
  for (int i = 0; i < r; ++i){
    int p = 0;
    int c = 0;
    cin >> p; cin >> c;
    rotate(A,A+p-1,A+p-1+c);
  }

  cout << A[0] << endl;

}

return 0;

}

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

using namespace std;

int main(){
	int n, r;
	vector<int> card;
	vector<int> card2;
	while(true){
		cin >> n >> r;
		if(!n && !r) break;
		card.clear();
		// 1 .. n
		for(int i = 1; i <=n ; i++){
			card.push_back(i);
		}

		for(int i = 0; i < r; i++){
			int p, c;

			cin >> p >> c;
			if(n == c) continue;
			
			vector<int>::iterator it = card.end() - p - c + 1;
			
			// temp
			for(int j = 0; j < c; j++){
				card.push_back(*it);
				it++;
			}
			
			
			//erase
			card.erase(it  - c, it);
			
			it = card.begin();
			while(it != card.end()){
				cout << " " << *it ;
				it ++;
			}
			cout << endl;
			
		}
		cout << card[n-1] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int N, R, p, c;
int main() {
    while (cin >> N >> R && N) {
        vector <int> A(N,0);
        for (int i = 0; i < N; ++i) A[i] = N - i;
        for (int i = 0; i < R; ++i) {
            cin >> p >> c;
            rotate(A.begin(), A.begin()+p-1,A.begin()+c+p-1);
        }
        cout << A[0] << endl;
    }
    return 0;
}

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 <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 28)

template<typename T>
void remove(vector<T>& vector, unsigned int index){
vector.erase(vector.begin() + index);
}
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int main(void){
	int n, r;
	while(cin >> n >> r, n | r){
		int card[n];
		card[0] = n;
		for(int i = 1; i < n; i++)card[i] = card[i-1]-1;
		rep(i,r){
			int p, c;
			cin >> p >> c;
			int abv[p];
			for(int j = 0; j < p-1; j++){
				abv[j] = card[j];
			}
			for(int j = 0; j < c; j++){
				card[j] = card[p-1+j];
			}
			for(int j = 0; j < p; j++){
				card[c+j] = abv[j];
			}
		}
		cout << card[0] << endl;
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
using namespace std;

int n,r,p,c;
int before[50],after[50];

void init(){
	for(int i=0;i<50;i++)
		before[i]=after[i]=0;
}

bool input(){	
	int i;
	cin>>n;
	cin>>r;
	if((n==0) && (r==0))
		return false;
	for(i=0;i<n;i++){
		before[i]=n-i;
		after[i]=n-i;
	}
	return true;
}

void Shuffle(int b[], int a[]){
	int j;
	for(j=0;j<c;j++)
		a[j]=b[p-1+j];
	for(j=0;j<p-1;j++)
		a[c+j]=b[j];
	for(j=0;j<n;j++)
		b[j]=a[j];
}


int solve(){
	for(int i=0;i<r;i++){
		cin>>p>>c;
		Shuffle(before,after);
	}
	return after[0];
}


int main(){
  while(init(),input()){
	cout<<solve()<<endl;
  }
  return 0;
}