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
//------------------------------------------
#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>
using namespace std;

//conversion
//------------------------------------------
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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//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);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//??????1??????N
int main(){
	VI Hanafuda;
	deque<int> HanafudaBuf;
	int N;
	int R;
	int p;
	int c;
	int r=INT_MIN;
	while (true){
		if (r != INT_MIN){ cout << endl; }
		cin >> N;
		cin >> R;
		if (N == 0 && R == 0){ break; }
		FOR(i, 1, N + 1){
			Hanafuda.push_back(i);
		}
		FOR(i, 0, R){
			cin >> p;
			cin >> c;
			for (int j = N - p; j >= N - p - c + 1; j--){
				HanafudaBuf.push_front(Hanafuda[j]);
			}
			if (p != 1 && c != N){ Hanafuda.erase(Hanafuda.begin() + p - 1, Hanafuda.begin() + p + c - 1); }
			for (int j = 0; j < c; j++){
				Hanafuda.push_back(HanafudaBuf[j]);
			}
		}
		r = Hanafuda[N - 1];
		cout << r;
		Hanafuda.clear();
		HanafudaBuf.clear();
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int n,r;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  while (cin >> n >> r, n) {
    vector<int> v(n);
    iota(ALL(v),1);
    REV(v);
    REP(i,r) {
      int p,c;
      cin >> p >> c;
      vector<int> w(n);
      for (int j = 0; j < c; j++) {
        w[j] = v[p-1+j];
      }
      for (int j = 0; j < p-1; j++) {
        w[j+c] = v[j];
      }
      for (int j = c+p-1; j < n; j++) {
        w[j] = v[j];
      }
      v = w;
    }
    cout << v[0] << endl;
  }

  return 0;
}

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

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

  while(cin >> n >> r && n)
  {
    int yama[n];
    for(int i = 0; i < n; i++)
    {
      yama[i] = n-i;
    }
    for(int i = 0; i < r; ++i)
    {
      cin >> p >> c;
      rotate(yama,yama+p-1,yama+ p+ c -1);
    }
    printf("%d\n", yama[0] );
  }
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int main(){
  int n, r;
  while(scanf("%d%d", &n, &r) && n && r){
    vector<int>a(n);
    rep(i, n) a[i] = n-i;
    int p, c;
    //    rep(i, n) printf("%d ", a[i]); puts("");
    while(r--){
      scanf("%d%d", &p, &c);
      p--;
      vector<int>tmp(c);
      REP(i, p, p + c) tmp[i-p] = a[i];
      for(int i = p; i >= c; --i) a[i] = a[i-c];
      rep(i, c) a[i] = tmp[i];
      //      rep(i, n) printf("%d ", a[i]); puts("");
      //      rep(i, c) printf("%d ", tmp[i]); puts("");
    }
    //    rep(i, n) printf("%d ", a[i]); puts("");
    printf("%d\n", a[0]);
  }
  return 0;
}

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

using namespace std;

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

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

using namespace std;

int main(){
	int n, r, p, c;
	while(cin >> n >> r, n|r){
		vector<int> res;
		for(int i = n;i >= 1;i--){
			res.push_back(i);
		}
		for(int i = 0;i < r;i++){
			cin >> p >> c;
			vector<int> tmp;
			for(int i = p-1;i < p + c-1;i++){
				tmp.push_back(res[i]);
			}
			for(int i = 0;i < n;i++){
				if(p-1 <= i && i < p + c - 1)continue;
				tmp.push_back(res[i]);
			}
			res = tmp;
		}
		cout << res[0] << endl;
	}
}