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>

using namespace std;

int n, r, p, c;
int cards[50];
int temp[50];

int main()
{
	while( 1 )
	{
		cin >> n >> r;
		if(n==0 && r==0) break;
		
		for(int i=0; i<n; i++) cards[i] = n-i-1;
		for(int i=0; i<r; i++)
		{
			cin >> p >> c;
			memcpy(&temp[0], &cards[p-1], sizeof(int) * c);
			memcpy(&temp[c], &cards[0], sizeof(int) * (p-1));
			for(int j=0; j<p+c-1; j++) cards[j] = temp[j];
		}
		printf("%d\n", cards[0]+1);
   	}
}

C++: #include <iostream>
#include <limits.h>
#include <vector>
#include <algorithm>

#define el endl
#define fd fixed

using namespace std;

int main() {
  int n, r, p, c;
  while (cin >> n >> r, n+r) {
    vector<int> yama;
    for (int i = n; i > 0; i--) yama.push_back(i);
    while (r--) {
      cin >> p >> c;
      rotate(yama.begin(), yama.begin()+p-1, yama.begin()+p-1+c);
    }
    cout << yama[0] << el;
  }
}

C++: //#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
//#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <set>
using namespace std;

int main(void){

	int n, r;
	// char ;

	while (scanf("%d %d", &n, &r) != EOF){
		if (n == 0 && r == 0) break;
		int card[100];
		for (int j = 1; j <= n; j++){
			card[j] = n - j + 1;
		}

		for (int i = 0; i < r; i++){
			int p, c;
			int buff[100];
			scanf("%d %d", &p, &c);

			for (int j = 0; j < c; j++){
				buff[j] = card[p + j];
			}

			for (int j = p + c - 1; j >= c + 1; j--){
				card[j] = card[j - c];
			}

			for (int j = 0; j < c; j++){
				card[j + 1] = buff[j];
			}

		}
		
		cout << card[1] << endl;

	}

	return 0;
}

/*
for(i=0;i<N;i++){
cin >> X[i];
}


for(i=0;i<N;i++){
for(j=0;j<N;j++){
cin >> X[i][j];
}
}
*/

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	for(int n, r ; cin >> n >> r, n || r; ) {
		vector<int> v(n);
		rep(i,n) v[i] = n - i;
		rep(i,r) {
			int p, c;
			vector<int> tmp;
			cin >> p >> c;
			rep(j,c) {
				tmp.pb(v[p+j - 1]);
			}
			rep(j,p - 1) {
				tmp.pb(v[j]);
			}
			for(int j = p + c - 1; j < n; j++) {
				tmp.pb(v[j]);
			}
#if 0
			preview(tmp.begin(), tmp.end());
#endif
			v = tmp;
		}
		cout << *v.begin() << endl;
	}
	return 0;
}

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

using namespace std;
int n, r, p, c;

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

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

int main(){
	int n, r, p, c;
	const int SIZE = 50;
	int card[SIZE];
	int P[SIZE], C[SIZE];
	
	while(true){
		scanf("%d%d", &n, &r);
		if(n == 0 && r == 0) break;
		
		for(int i = n; i > 0; i--){
			card[n - i] = i;
		}
		
		for(int i = 0; i < r; i++){
			scanf("%d%d", &p, &c);
			for(int j = 0; j < p - 1; j++) P[j] = card[j];
			for(int j = 0; j < c; j++) C[j] = card[j + p - 1];
			
			for(int j = 0; j < c; j++) card[j] = C[j];
			for(int j = 0; j < p - 1; j++) card[j + c] = P[j];
		}
		
		printf("%d\n", card[0]);
	}
	
	return 0;
}

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

int main(){
	int n,r,p,c;

	while(true){
		cin >> n >> r;
		if(n == 0 && r == 0){
			break;
		}

		int* cards = new int[n];
		for(int i=0;i<n;i++){
			cards[i] = n-i;
		}
		int* buf = new int[n];
		for(int i=0;i<r;i++){
			cin >> p >> c;
			for(int j=0;j<c;j++){
				buf[j] = cards[p+j-1];
			}
			int count = c;
			for(int j=0;j<n;j++){
				if(j<p-1 || p-1+c < j){
					buf[count] = cards[j];
					count++;
				}
			}

			for(int j=0;j<n;j++){
				cards[j] = buf[j];
			}
		}

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

C++: /*Hanafuda Shuffle*/
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> p;

int main(void){
  int d=0;
  int n,r,p,c;
  while(d==0){
    cin >> n >> r;
    if(n==0 && r==0)break;
    vector<int> a(n,0);
    for(int i=0;i<n;i++){
      a[i]=i+1;
    }
    reverse(a.begin(),a.end());
    for(int i=0;i<r;i++){
      cin >> p >> c;
      rotate(a.begin(),a.begin()+p-1,a.begin()+p-1+c);
    }
    cout << a[0] << endl;
  }
  return 0;
}

C++: #include <cstdio>
#include <cstring>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
int n,r;
int f[55],cp[55];
int main(void){
	for(;;){
		scanf("%d%d",&n,&r);
		if(n==0)break;
		rep(i,0,n)f[i]=n-i;
		rep(i,0,r){
			int a,b;
			scanf("%d%d",&a,&b);
			memcpy(cp,f,(a-1)*4);
			memcpy(f,f+a-1,b*4);
			memcpy(f+b,cp,(a-1)*4);
		}
		printf("%d\n",f[0]);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,r;

int main(){
	while(cin >> n >> r && n+r){
		vector<ll> v(n);
		rep(i,n)v[i] = n-i;
		rep(i,r){
			ll p,c;
			vector<ll> vv;
			cin >> p >> c;
			p--;
			rep(i,c)vv.push_back(v[p+i]);
			rep(i,n){
				if(i < p || i >= p+c)vv.push_back(v[i]);
			}
			v.clear();
			v = vv;
		}
		cout << v[0] << endl;
	}
}