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 main(){
  int n,r;
  int card[50],yama[50];
  while(cin >>n>>r,n||r){
    for(int i=0; i<n; i++) card[i] = n-i;
    for(int i=0,a,b; i<r; i++){
      cin >>a>>b;a--;
      for(int j=0; j<b; j++) yama[j] = card[a+j];
      for(int j=a-1; j>=0; j--) card[j+b] = card[j];
      for(int j=0; j<b; j++) card[j] = yama[j];
     }
    cout <<card[0]<<endl;
  }
  return 0;
}

C++: #pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

void Init() {
	std::cin.tie(0); std::ios::sync_with_stdio(false);
	struct Init_caller { Init_caller() { Init(); } }caller;
}

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INT_INF 1<<29
#define LL_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using ppi = pair<pi, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;
using vppi = vector<ppi>;

#pragma endregion

struct edge {
	int from, to, cost;
};

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}


#pragma endregion 


/*****************************************************************************/
signed main(void) {
	while (1) {
		int n, r;
		cin >> n >> r;
		if (n == 0 && r == 0)break;
		vector<int> a(n);
		for (int i = n; i > 0; i--) {
			a[n - i] = i;
		}
		for (int i = 0; i < r; i++) {
			int pos, num;
			cin >> pos >> num;
			vector<int> s(num);
			for (int j = 0; j < num; j++) {
				s[j] = a[pos - 1 + j];
			}
			a.erase(a.begin() + pos - 1, a.begin() + pos - 1 + num);
			/*for (auto i = a.begin(); i != a.end();i++) {
				cout << *i;
			}
			cout << endl << "!!!" << endl;*/
			for (auto ite = a.begin(); ite != a.end(); ite++) {
				s.push_back(*ite);
			}
			a.resize(n);
			copy(s.begin(), s.end(), a.begin());
			/*for (auto i = a.begin(); i != a.end(); i++) {
				cout << *i;
			}
			cout << endl << "???" << endl;*/
		}
		cout << a[0] << endl;
	}
	return 0;
}