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++: // includes
#include <bits/stdc++.h>

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define vrep(v, i) for(int i = 0; i < (v).size(); i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define FI first
#define SE second
#define dump(a, n) for(int i = 0; i < n; i++)cout << a[i] << "\n "[i + 1 != n];
#define dump2(a, n, m) for(int i = 0; i < n; i++)for(int j = 0; j < m; j++)cout << a[i][j] << "\n "[j + 1 != m];
#define bit(n) (1LL<<(n))
#define INT(n) int n; cin >> n;
#define LL(n) ll n; cin >> n;
#define DOUBLE(n) double n; cin >> n;
using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef complex<double> cd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// solve
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}


int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20);
  while(true){
  	INT(n); INT(r); if(n == 0 && r == 0)break;
  	vector<int> v(n); rep(i, n)v[i] = n - i;
  	rep(i, r){
  		INT(p); INT(c);
  		vector<int> nv = v;
  		rep(j, p - 1){
  			nv[c + j] = v[j];
  		}
  		rep(j, c){
  			nv[j] = v[p - 1 + j];
  		}
  		v = nv;
  	}
  	cout << v[0] << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std; 
int main(){
  int n,r;
  int a[60]={}; 
  while(cin>>n>>r){
    if(n==0&&r==0)break;
    for(int i=0;i<n;i++){
      a[i]=n-i;
    }
    int b[60]={};
    for(int i=0;i<r;i++){
      int p,c;
      cin>>p>>c;
      for(int j=0;j<c;j++){
	b[j]=a[p-1+j];	
      }
      for(int j=0;j<p-1;j++){
	b[j+c]=a[j];
      }
      for(int j=0;j<n-p-c+1;j++){
	b[j+p+c-1]=a[j+p+c-1];
      }

      for(int i=0;i<n;i++){	
	a[i]=b[i];
      }
    }
    cout<<b[0]<<endl;
  }  
  return 0;
}

C++: #include <stdio.h>
??
int main() {
??
????int r,d,n,i,j,k,l;
????int p,c;
????int a[60] = {0};
????int b[60] = {0};
??
??
????while(1) {
??
????????scanf("%d %d", &n, &r);
??
????????if(n == 0 && r == 0) {
????????????break;
????????}
??
??
????????for(i =0 ; i<=n ; i++) {
????????????a[n-1-i] = i+1;
????????????b[n-1-i] = i+1;
????????}
??
??
??
????????for(i = 0; i < r; i++) {
????????????scanf("%d %d",&p,&c);
??
????????????for(j = 0; j<c;j++) {
????????a[j] = b[p+j-1];
????????//printf("a[%d] = %d\n",j,a[j]);
????????????}
????????????for(j = 0;j<p-1;j++) {
????????a[c+j] = b[j];
????????//printf("a[%d] = %d\n" ,c+j ,a[c+j]);
????????????}
??
????????????for(j = 0;j<p+c-1;j++) {
????????b[j] = a[j];
????????????}
????????}
??
??
????????printf("%d\n",a[0]);
??
????}
??
????return 0;
}

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

using namespace std;

int main(){
	int n, r;
	while(cin >> n >> r, n || r){
		int p, c;
		stack<int> S,P,C;
		for(int i = 1; i <= n; i++){
			S.push(i);
		}
		while(r){
			cin >> p >> c;
			while(--p){
				P.push(S.top());
				S.pop();
			}
			while(c){
				C.push(S.top());
				S.pop();
				c--;
			}
			while(!P.empty()){
				S.push(P.top());
				P.pop();
			}
			while(!C.empty()){
				S.push(C.top());
				C.pop();
			}
			r--;
		}
		cout << S.top() << "\n";
	}
	return 0;
}

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

void cut(std::vector<int>&v, int p, int c){

	std::vector<int>vv(c);

	for (int i = 0, j = p - 1; i < vv.size(); i++, j++){
		vv[i] = v[j];
	}

	for (int i = p - 2; i >= 0; i--){
		v[i + c] = v[i];
	}

	for (int i = 0; i < c; i++){
		v[i] = vv[i];
	}

}

int main(){

	int n, r;

	while (std::cin >> n >> r){
		if (n == 0 && r == 0)break;
		std::vector<int>v(n);

		for (int i = v.size() - 1; i >= 0; i--)v[i] = v.size() - i;

		for (int i = 0; i < r; i++){
			int p, c;
			std::cin >> p >> c;
			cut(v, p, c);
		}

		std::cout << v[0] << std::endl;

	}
	return 0;
}

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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int n, r;
vector<int> p, c;
void ops(vector<int> &card, int p, int c) {
    auto tmp = card;
    rep(i, c) {
        card[i] = tmp[i + p - 1];
    }
    rep(i, p) {
        card[i + c] = tmp[i];
    }
}
void solve() {
    vector<int> card(n);
    rep(i, n) card[i] = n - i;
    rep(i, n) cout << card[i] << " ";
    cout << endl;
    rep(i, r) {
        ops(card, p[i], c[i]);
        // rep(i, n) cout << card[i] << " ";
        // cout << endl;
    }
    cout << card[0] << endl;
}
int main() {
    while (cin >> n >> r, n) {
        p.resize(r);
        c.resize(r);
        rep(i, r) cin >> p[i] >> c[i];
        solve();
    }

    return 0;
}