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 <vector>

using namespace std;

int main(){
	vector<int> cards;
	vector<int> ::iterator cardsIterator;
	vector<int> ::iterator shuffuleIterator;
	int n,r,p,c;

	while(cin >> n >> r, n && r){
		cards.clear(); //初期化
		// カードの山生成
		for (int i = 0; i < n; ++i){
			cards.push_back(i+1);
		}
		// シャッフル
		while(cin >> p >> c, r--){
			cardsIterator = cards.end();
			cardsIterator -= p + (c - 1);
			while(c--){
				cards.push_back(*cardsIterator);
				cards.erase(cardsIterator);
			}
			if (r == 0){
				break;
			}
		}
		// 一番上のカード表示
		cout << cards.back() << endl;
	}
}

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
const double PI = acos(-1);

int main() {
	int n, r, p, c;
	while (cin >> n >> r&&n&&r) {
		vector<int> vec;
		for (int i = n; i >= 1; i--) {
			vec.emplace_back(i);
		}
		for (int i = 0; i < r; i++) {
			cin >> p >> c;
			for (int j = 0; j < c; j++) {
				vec.insert(vec.begin(),vec[p + c - 2]);
				vec.erase(vec.begin() + p + c - 1);
			}
		}
		cout << vec[0] << endl;
	}
}

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

using namespace std;

long long INF=1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    while(1){
        int n,r;
        cin>>n>>r;
        if(n+r==0)break;

        vector<int> a(n);
        for(int i=0;i<n;i++)a[i]=n-i;

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

C++: #include<stdio.h>
int main(void){
	int p, c, count, n, r, huda[200] = {0}, i, j;
	while (1) {
		scanf("%d %d", &n, &r);
		for (i = 0;i < n;i++) {
			huda[i] = i + 1;
		}
		if (n == 0 && r == 0) {
			break;
		}
		for (i = 0;i < r;i++) {
			scanf("%d %d", &p, &c);

			for (j = 0;j < c;j++) {
				huda[n + j] = huda[n - p+j];
				huda[n - p+j] = -1;
			}

			count = 0;
			for (j = 0;j < n;j++) {

				if (count > n)
					break;
				huda[j] = huda[count];
				if (huda[count] == -1) {
					j--;
				}
				count++;

			}
		/*	for (j = 0;j < n;j++) {
				printf("%d ", huda[j]);
			}*/
		}
		printf("%d\n",huda[n-1]);
	}


	return 0;
}

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

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

using namespace std;

typedef vector<int> vi;

void pp(vi v){
	rep(i, v.size()){
		cout << v[i] << ' ';
	}
	cout << endl;
}

int main(){
	int n, r;

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

		if(!n && !r) break;

		n++;
		vi cards(n);
		rep(i, n){
			cards[i] = i;
		}

		int p, c;
		rep(i, r){
			cin >> p >> c;

			int index = n-(p-1+c);

			vi pick;
			// cardsの後ろからp-1+c番目からc個を保管
			rep(j,c){
				pick.push_back(cards[index+j]);
			}
		
			// cardsの後ろからp-1+c番目にp1番目-0をコピー
			rep(j, p-1){
				cards[index+j] = cards[index+j+c];
			}

			// 保管していたのを後ろに追加
			rep(j,c){
				cards[index+p-1+j] = pick[j];
			}

			//pp(cards);
		}
		cout << cards[n-1] << endl;
	}

	return 0;
}

C++: #include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h<<":";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

/* template end */

using ll = long long;
using P=std::pair<long long,long long>;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll n,r;
  
  while(std::cin>>n>>r,n||r){
    std::vector<ll> card(n);
    std::iota(card.rbegin(),card.rend(),1);
    rep(i,0,r){
      ll p,c;
      std::cin>>p>>c;
      std::vector<ll> temp;
      rep(j,p-1,p+c-1)temp.emplace_back(card[j]);
      rep(j,0,p-1)temp.emplace_back(card[j]);
      rep(j,p+c-1,n)temp.emplace_back(card[j]);
      card=temp;
    }

    std::cout<<card[0]<<"\n";
  }

  return 0;
}