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>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  while (true) {
    int n, r; cin >> n >> r;
    if (n == 0) break;
    vi32 a(n);
    iota(all(a), 1);
    reverse(all(a));
    rep(_, r) {
      vi32 b = a;
      int p, c; cin >> p >> c;
      rep(i, c) b[i] = a[i + p - 1];
      rep(i, p - 1) b[i + c] = a[i];
      a = b;
    }
    cout << a[0] << '\n';
  }
}

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

int main()
{
	int n,r;
	while(cin >> n >> r){
		if(!n && !r)
			break;
		int p,c;
		int card[50];
		for(int i=0;i<n;i++){
			card[i] =  i+1;
		}
		for(int i=0;i<r;i++){
			cin >> p >> c;
			int tmp[50];
			for(int j=0;j<n;j++){
				tmp[j] = card[j];
			}
			int a = n-1;
			for(int j=0;j<c;j++){
				tmp[a--] = card[n-p-j];
			}
			for(int j=0;j<p-1;j++){
				tmp[a--] = card[n-1-j];
			}
			for(int j=0;j<n;j++){
				card[j] = tmp[j];
			}
		}
		cout << card[n-1] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<string> split(const string& str, char delimi) {
    vector<string> elem;
    string tmp;
    for (char c:str) {
        if (c == delimi) {
            if (!tmp.empty()) {
                elem.push_back(tmp);
            }
            tmp.clear();
        } else {
            tmp += c;
        }
    }
    if (!tmp.empty()) {
        elem.push_back(tmp);
    }
    return elem;
}
int main() {
    while(1) {
        string str;
        getline(cin, str);
        vector<string> line = split(str, ' ');
        int n = atoi(line[0].c_str());
        if (n == 0)
            break;
        int r = atoi(line[1].c_str());
        int card[n];
        for (int i = 0, num = n; i < n; ++i, --num) {
            card[i] = num;
        }
        for (int i = 0; i < r; ++i) {
            string str;
            getline(cin, str);
            vector<string> line = split(str, ' ');
            int p = atoi(line[0].c_str());
            int c = atoi(line[1].c_str());
            rotate(card, card + p - 1, card + p + c - 1);
        }
        cout << card[0] << endl;
    }
}

C++: #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 <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;

//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())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second


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

int v[2][55];

int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0)return 0;
		REP(i,n)v[0][i]=n-i;
		REP(i,m){
			int p,c;
			cin>>p>>c;
			p--;
			copy(&v[i%2][0], &v[i%2][n], &v[(i+1)%2][0]);
			copy(&v[i%2][0], &v[i%2][p], &v[(i+1)%2][c]);
			copy(&v[i%2][p], &v[i%2][p+c], &v[(i+1)%2][0]);
		}
		cout << v[m%2][0] << endl;
	}
}