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 <vector>

using namespace std;

int main() {
    while(true) {
        int N, R;
        cin >> N >> R;
        if(!N && !R) break;

        vector<int> cards(N);
        for(int i = 0; i < N; ++i) cards[i] = N-i;

        while(R--) {
            int P, C;
            cin >> P >> C;
            P--;
            vector<int> tmp;
            for(int i = 0; i < C; ++i) tmp.push_back(cards[P+i]);
            for(int i = 0; i < P; ++i) tmp.push_back(cards[i]);
            for(int i = P+C; i < N; ++i) tmp.push_back(cards[i]);
            cards = tmp;
        }

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

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  while(true){
	int N, R; cin >> N >> R;
	if(N == 0 && R == 0) break;
	VI card(N+1);
	REP(i,N+1)
	  card[i] = N + 1 - i;
	REP(r,R){
	  int p, c; cin >> p >> c;
	  for(int i=0;i<c;++i){
		int tmp = card[p + i];
		for(int j=p;j>=1;--j)
		  card[i+j] = card[i+j-1];
		card[i+1] = tmp;
	  }
	  //	  for(int i=1;i<=N;++i)cout<<card[i]<<endl;cout<<endl;
	}
	cout << card[1] << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main()
{
	int n,r;
	while(cin>>n>>r,n) 
	{
		string deck;
		for(int i = n; 0 < i; --i)
		{
			deck+='0'+i;
		}

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

			string t,m,b;
			t=deck.substr(0,p-1);
			m=deck.substr(p-1,c);
			b=deck.substr(p-1+c-1);

			deck=m+t+b;
		}
		cout<<deck[0]<<endl;
	}
  return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define rrep(i,n) for(int i = n - 1; i >= 0; i--)
#define REP(i,k,n) for(int i = k; i < n; i++)

#define vi vector<int>
#define pb push_back
using namespace std;

int main(){
    int n,r;
    while(cin >> n >> r,n) {
        vi card(n);

        rep(i,n) card[i] = n - i;
        rep(i,r){
            cin >> p >> c;
            vi tmp(c);
            rep(j,c) tmp[c] = card[p - 1 + j];
            rrep(j,p - 1) card[j + c - 1] = card[j];
            rep(j,c) card[j] = tmp[c];
        }
        cout << card[0] << endl;
    }
    return 0;

}

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

int main(){
	while(1){
		int n,r,p,c;
		cin >> n >> r;
		if(n == 0 && r ==0)break;
		int s[n + 1];
		for(int i = 1; i <= n;++i){
		s[i] = i;
		}
		for(int j = 0; j < r;++j){
			cin >> p >> c;
			if(p == 1)continue;
			for(int k = 0;k < c;++k){
				s[0] = s[n + 2 - p - c];
				for(int l = 0;l < p + c - 2;++l){
					s[n + 2 - p - c + l] = s[n + 3 - p - c + l];
					}
				s[n] = s[0];
			}
		}
		  cout << s[n] << endl;

	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false);
	int n, r;
	while (cin >> n >> r, n)
	{
		vi v;
		REP(i, n) v.push_back(i + 1);
		REP(i, r)
		{
			int c, p; cin >> p >> c;
			int a = n - c - p + 1;
			int b = n - p + 1;
			vi w;
			REP(i, a) w.push_back(v[i]);
			FOR(i, b, n) w.push_back(v[i]);
			FOR(i, a, b) w.push_back(v[i]);
			v = w;
		}
		cout << v.back() << endl;
	}

	return 0;
}

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

using namespace std;

int main(void){

  int n,r;
  while(cin >> n >> r,n|r){
    vector<int>a(n);
    for(int i=0;i<n;i++)a[i]=i;

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

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

using namespace std;

int main()
{
    while (true) {
        int n;
        int r;
        cin >> n >> r;

        if (n == 0 && r == 0) {
            break;
        }

        vector<int> v(static_cast<size_t>(n));
        iota(begin(v), end(v), 1);
        reverse(begin(v), end(v));
        for (int i = 0; i < r; ++i) {
            int p;
            int c;
            cin >> p >> c;
            vector<int> t;
            copy_n(begin(v) + (p - 1), c, back_inserter(t));
            copy_n(begin(v), p, back_inserter(t));
            copy(begin(v) + (p - 1) + c, end(v), back_inserter(t));
            v = t;
        }
        cout << v[0] << endl;
    }
}