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>
#include<algorithm>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)

int main(){
  int n, r;
  while(cin >>n >>r && n){
    vector<int> v;
    for(int i = n; i > 0; i--) v.push_back(i);

    rep(i, r){
      int p, c;
      cin >>p >>c;
      vector<int> next;
      for(int i = 0; i < c; i++) next.push_back(v[p - 1 + i]);
      for(int i = 0; i < p - 1; i++) next.push_back(v[i]);
      for(int i = p + c - 1; i < v.size(); i++) next.push_back(v[i]);
      v = next;
    }
    cout <<v[0] <<endl;
  }
  return 0;
}

C++: #include<stdio.h>

int main(){
	int a[52],b[52],p,c,i,j,n,r;
	while(1){
		scanf("%d %d",&n,&r);
		if(n==0&&r==0)break;
		for(i=1;i<=n;i++)a[i-1]=n-i+1;
		while(r--){
			//for(i=0;i<n;i++)printf("%d ",a[i]);
			//printf("\n");
			scanf("%d %d",&p,&c);
			for(i=0;i<c;i++)b[i]=a[p+i-1];
			for(i=p-2;i>=0;i--)a[i+c]=a[i];
			for(i=0;i<c;i++)a[i]=b[i];
		}
		printf("%d\n",a[0]);
	}
	return 0;
}

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

int main(void)
{
	while ( true ) {
		std::vector<int> yama;
		int n, r;

		std::cin >> n;
		std::cin >> r;

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

		yama.resize(n);

		for ( int i = 0; i < n; ++i ) {
			yama[i] = i + 1;
		}

		for ( int i = 0; i < r; ++i ) {
			int p, c;
			std::cin >> p;
			std::cin >> c;

			int b = n - p;

			std::vector<int> d(c);

			for ( int j = 0; j < c; ++j ) {
				d[c - j -1] = yama[b - j];
			}

			for ( int j = b; j < n; ++j ) {
				yama[j - c] = yama[j];
			}

			for ( int j = n - c; j < n; ++j ) {
				yama[j] = d[j - n + c];
			}
			for ( int i = 0; i < n; ++i ) {
				std::cout << yama[i] << std::endl;
			}
		}

		std::cout << yama[n - 1] << std::endl;
	}
	return 0;
}

C++: #include<cstdio>

using namespace std;

int main(){
	for(int n,r;scanf("%d%d",&n,&r),n;){
		int q=0;
		while(r--){
			int p,c; scanf("%d%d",&p,&c);
			if     (q<c)     q+=p-1;
			else if(q<c+p-1) q-=c;
		}
		printf("%d\n",n-q);
	}

	return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,r,c,p;
    vector<int> s,s2;
    while(1){
        cin >> n >> r;
        if(n==0&&r==0)  break;
        for(int i=1;i<=n;i++){
            s.push_back(i);
        }
        while(r--){
            cin >> p >> c;
            for(int i=0;i<n-c-p+1;i++){
                s2.push_back(s[i]);
            }
            for(int i=n-p+1;i<n;i++){
                s2.push_back(s[i]);
            }
            for(int i=n-c-p+1;i<n-p+1;i++){
                s2.push_back(s[i]);
            }
            s.clear();
            for(int i=0;i<n;i++){
                s.push_back(s2[i]);
            }
            s2.clear();
        }
        cout << s[n-1] << "\n";
        s.clear();
    }
}

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

#define int long long


signed main()
{
    int n, r;
    while(cin>>n>>r, n) {
        vector<int> v(n);
        for(int i=0; i<n; ++i) v[i] = n-i;
        for(int j=0; j<r; ++j) {
            int p, c;
            cin >> p >> c;
            p--;
            vector<int> tmp;
            for(int i=p; i<p+c; ++i) tmp.push_back(v[i]);
            for(int i=0; i<p; ++i) tmp.push_back(v[i]);
            for(int i=p+c; i<n; ++i) tmp.push_back(v[i]);
            v = tmp;
        }
        cout <<v[0] << endl;
    }
    return 0;
}