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>                                             
                                                                     
using namespace std;                                                 
                                                                     
int main() {                                                         
                                                                     
    int n, r, p, c;                                                  
                                                                     
    while(cin >> n >> r, n | r) {                                    
                                                                     
        int fuda[n];                                                 
                                                                     
        for(int i = 0; i < n; ++i) {                                 
            fuda[i] = n - i;                                         
        }                                                            
                                                                     
        for(int i = 0; i < r; ++i) {                                 
                                                                     
            cin >> p >> c;                                           
                                                                     
            int temp[p + c - 1];                                     
                                                                     
            for(int j = 0; j < p - 1; ++j) {                         
                temp[c + j] = fuda[j];                               
            }                                                        
                                                                     
            for(int j = 0; j < c; ++j) {                             
                temp[j] = fuda[p + j - 1];                           
            }                                                        
                                                                     
            for(int j = 0; j < p + c - 1; ++j) {                     
                fuda[j] = temp[j];                                   
            }                                                        
                                                                     
        }                                                            
                                                                     
        cout << fuda[0] << endl;                                     
                                                                     
    }                                                                
                                                                     
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 28)

template<typename T>
void remove(vector<T>& vector, unsigned int index){
vector.erase(vector.begin() + index);
}
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int main(void){
	int n, r;
	while(cin >> n >> r, n | r){
		int card[n];
		card[0] = n;
		for(int i = 1; i < n; i++)card[i] = card[i-1]-1;
		rep(i,r){
			int p, c;
			cin >> p >> c;
			int abv[p];
			for(int j = 0; j < p; j++){
				abv[j] = card[j];
			}
			for(int j = 0; j < p; j++){
				card[j] = card[p+j];
			}
			for(int j = 0; j < p; j++){
				card[c+j] = abv[j];
			}
		}
		cout << card[0]+1 << endl;
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;


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

	while(cin >> n >> r){
		if((n==0)&&(r==0)){return 0;}
		for(int i=0; i<n; i++){
			card[i] = i+1;
		}
		cin >> p >> c;
		for(int i=0; i<r; i++){
			rotate(card.begin(),card.begin()+p, card.begin()+p-1+c);
		}
		cout << card[0] << endl;
	}
}

C++: #include <cstdio>
#include <iostream>
#include <list>

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

C++: #include<iostream>
#include<deque>
using namespace std;
int main()
{
	int n,r,c,p,i;
	while(cin>>n>>r,n)
	{
		deque<int>d(n);
		deque<int>::iterator x,y,z;
		for(i=0;i<n;++i)d[i]=n-i;
		while(r--)
		{
			cin>>p>>c;
			x=d.begin();y=x+p-1,z=y+c;
			deque<int>_(y,z);
			d.erase(y,z);
			d.insert(d.begin(),_.begin(),_.end());
		}
		cout<<d[0]<<endl;
	}
	return 0;
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
using namespace std;
typedef long long  ll;

/** Problem1129 : Hanafuda Shuffle **/
int main()
{
	vector<int> card;
	int n, r, p, c;
	
	while (cin >> n >> r, n||r) {
		card.clear();
		rep(i, n)
			card.push_back(n-i);
		
		rep(k, r) {
			cin >> p >> c;
			vector<int> tmp;
			rep(i, c)
				tmp.push_back(card[i+p-1]);
			rep(i, p-1)
				tmp.push_back(card[i]);
			REP(i, p+c-1, n) {
				tmp.push_back(card[i]);
			}
			card = tmp;
		}
		cout << card[0] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
    vector<int> vec;
    int n,m;
    int x,y,z;
    while(1){
        vec.clear();
        cin >> n >> m;
        if(n == 0 && m == 0)break;
        for(int i = 0;i < n;i++){
            vec.push_back(i+1);
        }
        for(int i = 0;i < m;i++){
            cin >> x >> y;
            vector<int>::iterator ite = vec.end() - (x+y-1);
            for(int j = 0;j < y;j++){
                z = *ite;
                vec.erase(ite);
                vec.push_back(z);
            }
        }
        cout << vec.back() <<endl;
    }
    return 0;
}