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

int main(){
  int n, r;
  int p, c;
  vector<int> card;
  vector<int> store;

  while(true){
    cin >> n >> r;

    if(n == 0 && r == 0) break;

    for(int i=n; i>0; i--){
      card.push_back(i);
      store.push_back(0);
    }
  
    for(int i=0; i<r; i++){
      cin >> p >> c;      
    
      int start = p;
      int count = 0;
      for(int j=p; j<p+c; j++){
	store[count++] = card[p-1];
      }

      count = 0;
      for(int j=c; j<n+1; j++){
	if(j <= p)	
	  store[j] = card[p - p + count++];
	else 
	  store[j] = card[j];
      }    

      for(int j=0; j<n; j++)
	card[j] = store[j];
    }

    cout << card.front() << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
using namespace std;

int main(){
	int n=1,r=1;
	int i,j;
	int c,p;
	cin>>n>>r;
	while(!(n==0&&r==0)){
		int x[100];
		queue<int> q;
	
	//cout<<n<<" "<<r<<endl;
	for(i=1;i<=n;i++){
		x[i] = i;
	}
	for(i=0;i<r;i++){
		cin>>p>>c;
		for(j=0;j<c;j++){
			q.push(x[n-p+1-j]);
		}
		for(j=0;j<p;j++){
			q.push(x[n-j]);
		}
		for(j=0;j<p+c;j++){
			x[n-j]=q.front();
			q.pop();
		}
	}
	cout<<x[n]<<endl;
		cin>>n>>r;
	}
	return 0;
}

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

int main(){
  int n,r,p,c,a[50];
  while(1){
    cin>>n>>r;
    if(n==0 && r==0)break;

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

C++: #include <cctype>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define LL long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;

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

int main(){
	int n, r;

	while(cin >> n >> r, n + r){
		int huda[51];
		REP(i, n){
			huda[i] = n - i;
		}
		
		while(r--){
			int p, c;
			int tmp[c];
			cin >> p >> c;
			
			REP(i, c){
				tmp[i] = huda[p + i - 1];
			}
			
			REPR(i, p - 2){
				huda[i + c] = huda[i];
			}

			REP(i, c){
				huda[i] = tmp[i];
			}
		}

		cout << huda[0] << endl;
	}
}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int n, r;
    while(cin>>n>>r, n) {
        vi v(n);
        rep(i,n) v[i] = n-i;
        rep(i,r) {
            vi tmp = v;
            int p, c;
            cin >> p >> c;
            rep(j,p-1) tmp[j+c] = v[j];
            rep(j,c) {
                tmp[j] = v[j+p-1];
            }
            swap(tmp,v);
        }
        P(v[0]);
    }
    return 0;
}

C++: #include <bits/stdc++.h>

int n = 0;

void display(int *arr){
  for(int i = 0; i < n; i++){
    std::cout << arr[i] << " ";
  }
  std::cout << std::endl;
}

int main(){

  /*std::vector<int> tmp;
  for(int i = 0; i < 10; i++){
    tmp.push_back(i);
    std::cout << tmp[i] << " ";
  }
  std::cout << std::endl;

  tmp.erase(tmp.end() - 6, tmp.end() - 3);
  for(int i = 0; i < tmp.size(); i++){
    std::cout << tmp[i] << " ";
  }

  std::cout << std::endl;*/
  
  while(1){
    int r;
    std::cin >> n >> r;    
    if(n + r == 0) break;
    std::vector<int> yama;
    for(int i = 0; i < n; i++){
      yama.push_back(i);
      //std::cout << yama[i] << " ";
    }
    //std::cout << std::endl;

    for(int i = 0; i < r; i++){
      int p, c;
      std::cin >> p >> c;
      std::vector<int> tmp;
      //std::cout << n << " " << r << " " << p << " " << c << std::endl;
      for(int j = 0; j < c; j++){
        tmp.push_back(yama[n - p - c + 1 + j]);
        //std::cout << tmp[j] << std::endl;
      }
      yama.erase(yama.end() - (p - 1 + c), yama.end() - (p - 1));
      //display(yama.data());
      for(int j = 0; j < tmp.size(); j++){
        yama.push_back(tmp[j]);
      }
    }
    std::cout << yama[yama.size() - 1] + 1 << std::endl;
    
  }

  return 0;
  
}

C++: #include <cstdio>
 
using namespace std;
 
int n, r;
int cards[2][51];
 
int main() {
  while (true) {
    scanf("%d %d", &n, &r);
    if (n == 0 && r == 0) break;
    for (int i=0;i<n;i++) cards[0][i] = n-i;
    for (int i=0;i<r;i++) {
      int p, c;
      scanf("%d %d", &p, &c);
      for (int j=0;j<c;j++) {
        cards[(i+1)&1][j] = cards[i&1][p-1+j];
      }
      for (int j=0;j<p-1;j++) {
        cards[(i+1)&1][c+j] = cards[i&1][j];
      }
      for (int j=p-1+c;j<n;j++) {
        cards[(i+1)&1][j] = cards[i&1][j];
      }
    }
    printf("%d\n", cards[r&1][0]);
  }
}