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

int card[1000], tmp[1000], n, r;
int main()
{
loop:
  cin >> n >> r;
  if(!(n || r))
    return 0;
  for(int i = n; i > 0; i--)
    card[n - i] = i;
  for(int i = 0; i < r; i++)
  {
    int c, p;
    cin >> p >> c;
    for(int j = 0; j < p - 1; j++)
      tmp[j] = card[j];
    for(int j = 0; j < c; j++)
      card[j] = card[j + p - 1];
    for(int j = 0; j < p - 1; j++)
      card[j + c] = tmp[j];
  }
  cout << card[0] << endl;
  goto loop;
}

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

using namespace std;

int main() {
    while (1) {
        int n, r;
        cin >> n >> r;
        
        if (n * r == 0) break;
        vector<int> card;
        
        for (int i = 0; i < n; ++i) {
            card.push_back(n - i);
        }

        for (int i = 0; i < r; ++i) {
            int p, c;
            cin >> p >> c;
            for (int k = 0; k < c; ++k) {
                int temp = card[c + p - 2];
                card.erase(card.begin() + c + p - 2);
                card.insert(card.begin(), temp);
            }
        }

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

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

using namespace std;

int N, R, p, c, i, j;

int main()
{
   while ( cin >> N >> R && N >0 )
   {
      int A[N];
      for ( i = 0; i < N; i++)
         {
            A[i] = N - i;
         }
      for ( j = 0; j<R; j++)
         {
            cin >> p >> c;
            rotate(A,A+(p-1),A+(p+c-1));
         }
      cout << A[0] <<endl;
   }
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
using namespace std;
int x[100];
int y[100];
int card [100];
int n,r;
int ans[1000];
int counter;
bool input(){
    for(int i=0;i<100;i++){
    x[i]=0;
    y[i]=0;
    }
    cin >>n>>r;
    for(int i=0;i<r;i++){
    cin>>x[i]>>y[i];
    }
  if(n==0){
    return false;
    }
    else{
     return true;
    }
}
void solve(){
    for(int i=0;i<100;i++){
        card[i]=i+1;
    }
    for(int i=0;i<r;i++){
        for(int k=0;k<y[i];k++){
            int a=card[x[i]+y[i]-2];
            for(int j=x[i]+y[i]-1;j>0;j--){
                card[j]=card[j-1];
            }
            card[0]=a;
       
        }
    }
    cout<<n-card[0]+1<<endl;
  //  ans[counter]=n-card[0];
    counter+=1;
}
    
    
    
int main (){
counter=0;
    while(input()){
    solve();
    }
return 0;
}
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
using namespace std;
int x[100];
int y[100];
int card [100];
int n,r;
int ans[1000];
int counter;
bool input(){
    for(int i=0;i<100;i++){
    x[i]=0;
    y[i]=0;
    }
    cin >>n>>r;
    for(int i=0;i<r;i++){
    cin>>x[i]>>y[i];
    }
  if(n==0){
    return false;
    }
    else{
     return true;
    }
}
void solve(){
    for(int i=0;i<100;i++){
        card[i]=i+1;
    }
    for(int i=0;i<r;i++){
        for(int k=0;k<y[i];k++){
            int a=card[x[i]+y[i]-2];
            for(int j=x[i]+y[i]-1;j>0;j--){
                card[j]=card[j-1];
            }
            card[0]=a;
       
        }
    }
    cout<<n-card[0]+1<<endl;
  //  ans[counter]=n-card[0];
    counter+=1;
}
    
    
    
int main (){
counter=0;
    while(input()){
    solve();
    }
return 0;
}

C++: #include <iostream>
#include <array>
#include <algorithm>

using namespace std;

int main()
{
  int N, R, p, c;
  // ???????????????????????¨???????????????                                                                                         
  while(cin >> N >> R && N){
    // ?±±?????????                                                                                                         
    array<int, 50> A;
    for(int i=0; i<N; i++){
      A[i] = N - i;
    }
    // ?????£?????????                                                                                                       
    for(int i=0; i<R; i++){
      cin >> p >> c;
      if(p == 1) continue;
      rotate(begin(A), begin(A) + p - 1, begin(A) + p + c - 1);
    }
    cout << A[0] << endl;
  }
}

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

int main(){
  int card[50],tmp[50];
  int n,r,p,c;

  while(cin >> n >> r,n){
    for(int i=0;i<n;i++)card[i] = n-i;

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

      for(int i=0;i<c;i++)tmp[i] = card[p-1+i];
      for(int i=p-1;i>=0;i--)card[i+c] = card[i];
      for(int i=0;i<c;i++)card[i] = tmp[i];
    }
    cout << card[0] << endl;
  }
}

C++: #include<stdio.h>

int main() {

	int n, r;
	int array[51];
	int tmp[51];
	while (1) {
		scanf("%d %d", &n, &r);
		if (n == 0 && r == 0) break;

		for (int i = 1; i <= n; i++) {
			array[i] = i;
		}
		for (int i = 0; i < r; i++) {
			int p, c;
			scanf("%d %d", &p, &c);
			for (int j = 0; j < c; j++) {
				tmp[j] = array[n - (p - 1) - j];
			}
			for (int j = 0; j < (p - 1); j++) {
				array[n - (p - 1) - c + 1 + j] = array[n - (p - 1) + 1 + j];
			}
			for (int j = 0; j < c; j++) {
				array[n - c + 1 + j] = tmp[c - 1 - j];
			}
		}
		printf("%d\n", array[n]);
	}
}

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

int main()
{
	
		int n, r, c, p, i, j, k,count=0, yama[50], hikae[50],ans[50];
		while (1)
		{
			cin >> n >> r;
			if (n == 0)
				break;
			for (i = 0; i < n; i++)
			{
				yama[i] = i + 1;
			}
			for (i = 0; i < r; i++)
			{
				cin >> p >> c;
				for (j = 0; j < n - p - c + 1; j++)
					hikae[j] = yama[j];
				for (k = 0; k < c; k++)
					hikae[n - k - 1] = yama[n - p - k];
				for (k = 0; k < p - 1; k++)
					hikae[n - c - k - 1] = yama[n - k - 1];
				for (j = 0; j < n; j++)
					yama[j] = hikae[j];
			}
			ans[count] = yama[n - 1];
			count++;
		}
		for (i = 0; i < count; i++)
			cout << ans[i] << endl;
	return 0;
}

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

int main(){
  int n,k;
  while(1){
    cin >> n >> k;
    if(n==0&&k==0) break;
    vector<int> card(n+1,0);
    for(int i=1;i<n+1;++i) card[i]=n-i+1;

    //for(int i=1;i<n+1;++i){
      //cout << card[i] << endl;
    //}

    for(int i=0;i<k;++i){
      int p,c;
      cin >> p >> c;
      rotate(card.begin()+1,card.begin()+p,card.begin()+p+c);
      for(int j=1;j<n+1;++j){
	//cout << card[j] << endl;
      }
    }
    cout << card[1] << endl;
  }
}

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

int main(){
  int n,r;
  stack<int> sp;
  stack<int> cp;
  list<int> m;
  while(cin>>n>>r,n|r){
    for(int i=1;i<=n;i++){
      m.push_back(i);
    }
    int p,c;
    while(r--){
      cin>>p>>c;
      for(int i=0;i<p-1;i++){
       	sp.push(m.back());
	m.pop_back();
      }
      for(int i=0;i<c;i++){
	cp.push(m.back());
	m.pop_back();
      }
      for(int i=0;i<p-1;i++){
       	m.push_back(sp.top());
	sp.pop();
      }
      for(int i=0;i<c;i++){
       	m.push_back(cp.top());
	cp.pop();
      }
    }
    cout<<m.back()<<endl;
  }
}