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++: Last login: Mon Apr 24 16:33:46 on ttys000
install-no-MacBook-Pro-4:~ g-2019$ cd zemi/
install-no-MacBook-Pro-4:zemi g-2019$ ls
#test.rb#	0417		0424
install-no-MacBook-Pro-4:zemi g-2019$ cd 0424
install-no-MacBook-Pro-4:0424 g-2019$ ls
#test.cpp#		atCoser-iroha.cpp	prac1_.cpp~
a.out			hanafuda.cpp		str.cpp
atCoder-B.cpp		hanafuda.cpp~		test.cpp
atCoder-B.cpp~		prac1_.cpp		test.cpp~
install-no-MacBook-Pro-4:0424 g-2019$ ./a.out
5 2
0
1
2
3
4
3 1
3 1
5
5 4 3 2 1               
0 0
install-no-MacBook-Pro-4:0424 g-2019$ emacs hanafuda.cpp























[1]+  Stopped                 emacs hanafuda.cpp
install-no-MacBook-Pro-4:0424 g-2019$ celar
-bash: celar: command not found
install-no-MacBook-Pro-4:0424 g-2019$ clear

install-no-MacBook-Pro-4:0424 g-2019$ g++ -Wall hanafuda.cpp
install-no-MacBook-Pro-4:0424 g-2019$ ./a.out
5 2 
0
1
2
3
4
3 1
3 1
4
4 3 5 2 1 
0 0
install-no-MacBook-Pro-4:0424 g-2019$ fg
emacs hanafuda.cpp

[1]+  Stopped                 emacs hanafuda.cpp
install-no-MacBook-Pro-4:0424 g-2019$ g++ -Wall hanafuda.cpp
hanafuda.cpp:22:5: error: no matching function for call to 'init'
    init(&yama, n);
    ^~~~
hanafuda.cpp:7:6: note: candidate function not viable: no known conversion from
      'vector<int> *' to 'vector<int> &' for 1st argument; remove &
void init(vector<int> &yama, int n);
     ^
1 error generated.
install-no-MacBook-Pro-4:0424 g-2019$ fg
emacs hanafuda.cpp

[1]+  Stopped                 emacs hanafuda.cpp
install-no-MacBook-Pro-4:0424 g-2019$ fg
emacs hanafuda.cpp

[1]+  Stopped                 emacs hanafuda.cpp
install-no-MacBook-Pro-4:0424 g-2019$ g++ -Wall hanafuda.cpp
hanafuda.cpp:22:5: error: no matching function for call to 'init_yama'
    init_yama(&yama, n);
    ^~~~~~~~~
hanafuda.cpp:7:6: note: candidate function not viable: no known conversion from
      'vector<int> *' to 'vector<int> &' for 1st argument; remove &
void init_yama(vector<int> &yama, int n);
     ^
1 error generated.
install-no-MacBook-Pro-4:0424 g-2019$ fg
emacs hanafuda.cpp

[1]+  Stopped                 emacs hanafuda.cpp
install-no-MacBook-Pro-4:0424 g-2019$ g++ -Wall hanafuda.cpp
install-no-MacBook-Pro-4:0424 g-2019$ ./a.out
5 2
3 1
3 1
0 0
4
install-no-MacBook-Pro-4:0424 g-2019$ fg
emacs hanafuda.cpp

[1]+  Stopped                 emacs hanafuda.cpp
install-no-MacBook-Pro-4:0424 g-2019$ g++ -Wall hanafuda.cpp
install-no-MacBook-Pro-4:0424 g-2019$ fg
emacs hanafuda.cpp

[1]+  Stopped                 emacs hanafuda.cpp
install-no-MacBook-Pro-4:0424 g-2019$ g++ -Wall hanafuda.cpp
hanafuda.cpp:27:7: error: no matching function for call to 'shuffle'
      shuffle(&yama, n, p, c);
      ^~~~~~~
hanafuda.cpp:7:6: note: candidate function not viable: no known conversion from
      'vector<int> *' to 'vector<int> &' for 1st argument; remove &
void shuffle(vector<int> &yama, int n, int p, int c);
     ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3122:10: note: 
      candidate function template not viable: requires 3 arguments, but 4 were
      provided
    void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
         ^
1 error generated.
install-no-MacBook-Pro-4:0424 g-2019$ fg
emacs hanafuda.cpp

[1]+  Stopped                 emacs hanafuda.cpp
install-no-MacBook-Pro-4:0424 g-2019$ g++ -Wall hanafuda.cpp
hanafuda.cpp:45:9: error: assigning to 'int' from incompatible type
      'vector<int>'
    tmp = yama[p-1+c-1];
        ^ ~~~~~~~~~~~~~
hanafuda.cpp:46:9: error: member reference type 'vector<int> *' is a pointer;
      did you mean to use '->'?
    yama.erase(yama.begin()+p-1+c-1);
    ~~~~^
        ->
hanafuda.cpp:46:20: error: member reference type 'vector<int> *' is a pointer;
      did you mean to use '->'?
    yama.erase(yama.begin()+p-1+c-1);
               ~~~~^
                   ->
hanafuda.cpp:47:9: error: member reference type 'vector<int> *' is a pointer;
      did you mean to use '->'?
    yama.insert(yama.begin(), tmp);
    ~~~~^
        ->
hanafuda.cpp:47:21: error: member reference type 'vector<int> *' is a pointer;
      did you mean to use '->'?
    yama.insert(yama.begin(), tmp);
                ~~~~^
                    ->
5 errors generated.
install-no-MacBook-Pro-4:0424 g-2019$ fg
emacs hanafuda.cpp

[1]+  Stopped                 emacs hanafuda.cpp
install-no-MacBook-Pro-4:0424 g-2019$ g++ -Wall hanafuda.cpp
install-no-MacBook-Pro-4:0424 g-2019$ fg
emacs hanafuda.cpp


#include <iostream>
#include <vector>
using namespace std;

//?±±?????????????????¢??°???????±±???????±±????????°n???p?????????????????????c???                       
void shuffle(vector<int> &yama, int n, int p, int c);


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

  cin >> n;
  cin >> r;

  while(n != 0 && r != 0){
    //?±±??????????????????                                                            
    for(int i = 0, j = n; i < n; i++, j--){
      yama.push_back(j);
    }
    //?????£?????????                                                                
    for (int i = 0; i < r; i++){
      cin >> p;
      cin >> c;
      shuffle(yama, n, p, c);
    }
    //???????????????????¨????                                                          
    v.push_back(yama.front());

    cin >> n;
    cin >> r;
  }
  for(int i = 0; i < v.size(); i++){
    cout << v[i];
  }
  cout << endl;
}

void shuffle(vector<int> &yama, int n, int p, int c){
  int tmp;

  for(int i = 0;i < c; i++){
-uuu:---F1  hanafuda.cpp   Top L41    (C++/l Abbrev)----------------------------

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

int main() {

  long long int n, r;

  while( true ) {

    cin >> n >> r;

    if ( n == 0 ) break;

    vector< long long int > m;

    for ( long long int i = 0; i < n; i++ ) {
      m.push_back( i+1 );
    }

    long long int p, c;

    for ( long long int i = 0; i < r; i++ ) {

      cin >> p >> c;
      for ( long long int j = 0; j < c; j++ ) {

	m.push_back( m[ n - p - c + 1 ] );
	vector<long long int>:: iterator it = m.begin() + n - p - c + 1;
	it = m.erase( it );

      }

    }

    cout << m[n-1] << endl;

  }

  return 0;

}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;

int main(){
	int N,R;
	while(cin>>N>>R,N||R){
		int P,C;
		vector<int> card;
		for(int i=1;i<=N;i++){
			card.push_back(i);
		}
		for(int i=0;i<R;i++){
			cin>>P>>C;
			vector<int>::iterator a,b;
			card.resize(card.size()+C);
			a = card.end()-C-P-C+1; b = card.end()-C-P+1;
			for(int j=0;j<C;j++){
				card[card.size()-(C-j)] = *(a+j);
			}
			card.erase(a,b);
		}
		printf("%d\n",card.back());
	}
	return 0;
}

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

int main(void)
{

	int n,r;
	int p,c;
	int i1,i2;

	while(1){

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

		vector<int> fuda(n),temp(n);

		/* syokika */
		for(i1=0;i1<n;i1++){
			fuda[i1] = n-i1;
	//		cout << fuda[i1] << " ";

		}


		for(i2=0;i2<r;i2++){
			
			cin >> p >> c;

			

			/* copy */
			for(i1=0;i1<p-1;i1++){
				temp[i1] = fuda[i1];
			}


			/* shuffle */
			for(i1=0;i1<c;i1++){
				fuda[i1] = fuda[p-1+i1];
			}
			for(i1=c;i1<p-1+c;i1++){
				fuda[i1] = temp[i1-c];
			}


	/*		for(i1=0;i1<n;i1++){
				cout << fuda[i1] << " ";
			}*/


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

	}

	return 0;
}