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 <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cmath>

using namespace std;

#define all(c) ((c).begin()),((c).end())
#define debug(c) cerr<<"> "<<#c<<" = "<<(c)<<endl;
#define iter(c) __typeof((c).begin())
#define tr(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(){
	for(int n, r; cin >> n >> r, (n | r) != 0; ) {
		vi cards(n);
		rep(i, n) cards[i] = n - i;
		rep(i, r) {
			int p, c; cin >> p >> c;
			rotate(cards.begin(), cards.begin() + p - 1, cards.begin() + p + c - 1);
		}
		cout << cards.front() << endl;
	}
	
	return 0;
}

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

int main() {
	while (1) {
		int n;//ÔDÌ
		int r;//VbtÌñ
		cin >> n >> r;
		if (n == 0 && r == 0) break;
		int cards[n];//J[h
		for (int i = 0; i < n; i++) {
			cards[i] = n - i;
		}
		//rñVbt·é
		for (int i = 0; i < r; i++) {
			int p, c;//pÚ©çc
			cin >> p >> c;
			int tmp[c];//ð·ÌêL¯p
			//tmpÉpÚ©çcði[
			for (int j = p - 1; j < p + c - 1; j++) {
				tmp[j - p + 1] = cards[j];
			}
			//tmpÉi[µ½ªðã«µÄlßé
			for (int j = p - 2; j >= 0; j--) {
				cards[j + c] = cards[j];
			}
			//tmpðãÉß·
			for (int j = 0; j < c; j++) {
				cards[j] = tmp[j];
			}
		}
		cout << cards[0] << endl;
	}
	return 0;
}

C++: #include<iostream>

#define rep(i,n) for(int i=0; i<n; i++)

int main(){
	int yama[51];
	int n,r;
	int tmp[51];

	while(std::cin >> n >> r && (n || r)){
		int c,p;
		rep(i,n){
			yama[i] = n-i;
		}
		rep(i,r){
			std::cin >> p >> c;
			rep(j,c){
				tmp[j] = yama[p-1+j];
			}
			rep(k,p-1){
				yama[p-1+c-k-1] = yama[p-1-k-1];
			}
			rep(l,c){
				yama[l] = tmp[l];
			}
		}
		std::cout << yama[0] << std::endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int n, r;
  while(cin >> n >> r, n || r){
    vector<int> card(n);
    for(int i = 0; i < n; i++)card[i] = i + 1;
    int p, c;
    for(int i = 0; i < r; i++){
      cin >> p >> c;
      p--;
      for(int j = p; j < p + c; j++){
        int tmp;
        tmp = card[card.size() - p - c];
        card.erase(card.begin() + card.size() - p - c);
        card.push_back(tmp);
      }
    }
    cout << card[n - 1] << endl;
  }
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n, r;
  while (cin >> n >> r, n) {
    vi v(n);
    rep(i, n) v[i] = n - i;
    rep(i, r) {
      int p, c;
      cin >> p >> c;
      vi w;
      w.reserve(c);
      for (int j = p - 1; j < p - 1 + c; j++) w.pb(v[j]);
      for (int j = p - 2; j >= 0; j--) v[j + c] = v[j];
      rep(j, w.size()) v[j] = w[j];
    }
    cout << v[0] << endl;
  }
}

C++: //Hanafuda Shuffle
#include <iostream>
#include <algorithm>
using namespace std;
int N, R, p, c;
int main() {
  while (cin >> N >> R && N>0) { //1??????????????????
    int A[N];
    for (int i=0; i<N; ++i) { //??±????????\???
      A[i] = N-i;
    }
    for (int i=0; i<R; ++i) { //?????£?????????
      cin >> p >> c;
      rotate(A, A+p-1, A+p+c-1);
    }
    cout << A[0] << endl;
  }
}

C++: #include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include <functional>
using namespace std;
typedef pair<int,int> mypair;

int main(void){
int n,r;
while(1)
{
cin>>n>>r;
if(n==0)break;
vector<mypair> huda(n);
mypair temp;
for(int i=0;i<n;i++){
	temp.first=n-i;
temp.second=n-i;
huda[i]=temp;
}


int p,c;
for(int i=0;i<r;i++){
	cin>>p>>c;
	for(int j=0;j<p-1;j++)
	huda[c+j].first=huda[j].second;
	for(int j=0;j<c;j++)
	huda[j].first=huda[p-1+j].second;
	for(int j=0;j<n;j++){
		huda[j].second=huda[j].first;
	}
	
}
//for(int i=0;i<n;i++)
//cout<<huda[i].first<<' '<<huda[i].second<<endl;
cout<<huda[0].second<<endl;
}
return 0;
}