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<bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9+7;

#define sx(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a),end(a)

int main(void) {
    int n,r;
    while (cin >> n >> r , n||r) {
        vector<int> a(n);
        REP(i,n) a[i] = n-i;
        REP(i,r) {
            int p,c;
            cin >> p >> c;
            vector<int> temp;
            REP(i,p-1) temp.pb(a[i]);
            a.erase(a.begin(), a.begin()+p-1);
            a.insert(a.begin()+c, ALL(temp));
        }
        cout << a[0] << endl;
    }
    return 0;
}

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

int solve(int n,int r){
    vector<int> m;
    for(int i=0;i<n;i++){
        m.push_back(i);
    }
    for(int i=0;i<r;i++){
        int p,c;
        scanf("%d %d",&p,&c);
        rotate(m.begin(),m.begin()+p-1,m.begin()+p+c-1);
    }
    return n-m[0];
}

int main(){
    while(1){
        int n,r;
        scanf("%d %d",&n,&r);
        if(n==0&&r==0) return 0;
        printf("%d\n",solve(n,r));
    }
}

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],tmp[50];

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

bool input(){	
	int i;
	cin>>n;
	cin>>r;
	for(i=0;i<n;i++)
		before[i]=n-i;	
	return 1;
}

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


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


int main(){
	n=r=1;
  while((n!=0)&&(r!=0)){
	init(),input();
	if(after[0]!=0)
		cout<<solve()<<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[55];
		for (int i = 0; i < r; i++){
			a[i] = i + 1;
		}
		for (int j = 0; j < r; j++){
			cin >> p >> c;
			rotate(a + n - p - c + 1, a + n - p + 1, a + n + 1);
		}
		cout << a[n - 1] << endl;
	}
	return 0;
}

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],tmp[50];

void init(){
	for(int i=0;i<50;i++)
		before[i]=after[i]=tmp[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;	
	return true;
}

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


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


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

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

int main() {
	// your code goes here
	long long n, r;
	std::vector<long long> arr1(60);
	std::vector<long long> arr2(60);
	while (1) {
		cin >> n >> r;
		if (n == 0 && r == 0) break;
		for (auto i = 0; i < 60; i++) arr1[i]=i;
		for (auto i = 0; i < r; i++) {
			long long p, c;
			cin >> p >> c;
			// cout << "input " << p << " " << c << endl;
			
			for (auto j = 0; j < c; j++) {
				long long copy_idx = n-p-c+j+2;
				// cout << "copy " << arr1[copy_idx] << endl;
				arr2[n-c+j+1] = arr1[copy_idx];
			}
			for (auto j = 0; j < p-1; j++) {
				arr1[n-p-c+j+2] = arr1[n-p+j+2];
			}
			for (auto j = 0; j < c; j++) {
				arr1[n-c+j+1] = arr2[n-c+j+1];
			}
		}
		cout << arr1[n] << endl;
	}
	return 0;
}

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

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

C++: #include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int main() {
  while (true) {
    int n, l;
    cin >> n >> l;
    if (n == 0) break;
    int cards[n], next[n];
    for (int i = n; i > 0; i--) {
      cards[n-i] = i;
    }

    for (int i = 0; i < l; i++) {
      int p, c;
      cin >> p >> c;
      for (int j = p-1; j < p+c-1; j++) {
	next[j-p+1] = cards[j];
      }
      for (int j = 0; j < p-1; j++) {
	next[c+j] = cards[j];
      }
      for (int j = p+c-1; j < n; j++) {
	next[j] = cards[j];
      }
      for (int j = 0; j < n; j++) {
	cards[j] = next[j];
      }
    }
    cout << cards[0] << endl;
  }
}

C++: #include <bits/stdc++.h>
#include <iterator>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(v) begin(v), end(v)
#define rreps(i, a, n) for (ll i = (a); i <= (ll)(n); ++i)
#define rrep(i, n) rreps(i, 0, n)
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define each(i, n) for (auto&& i : n)
#define fill(x, y) memset(x,y,sizeof(x))
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
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 (b<a) { a=b; return 1; } return 0; }
template <typename T> inline void print(const T& x) {cout << x << '\n';}

signed main()
{ 
  int n,r;
  vi ans;
  while(cin>>n>>r, n||r)
  {
    vi card(n);
    rep(i,n) card[i]=n-i-1;
    rep(k,r)
    {
      int p,c; cin>>p>>c;
      p--; c--;
      for(int j=p; j<p+c+1;j++)
      {
        for(int i=j; i>j-p; i--)
        {
          swap(card[i],card[i-1]);
        }
      }
    }
    ans.push_back(card[0]);
  }
  each(v,ans) print(v+1);
  return 0;
}

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

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

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