#include <stdio.h>
#include <stdlib.h>
#define TEST 10

void shuffle(int *card,int p,int c);

int main(void){
	int i,j,x,n,r,p,c;
	int *card;
	FILE *fp;
	fp = fopen("hanahuda.txt","r");
	if(fp == NULL){
		printf("ファイルが開けません\n");
		return -1;
	}
	while(1){
		x = fscanf(fp,"%d %d",&n,&r);
		if((n == 0) && (r == 0)){
			break;
		}
		card = (int *)calloc(n,sizeof(int));
		if(card == NULL){
			printf("メモリが確保できません\n");
			return -1;
		}
		for(i = 0;i < n; i++){
			card[i] = n - i;
		}
		for(i = 0;i < r; i++){
			x = fscanf(fp,"%d %d",&p,&c);
			shuffle(card,p,c);
		}

		printf("%d\n",card[0]);
		free(card);
	}
	return 0;
}

void shuffle(int *card,int p,int c){
	int box[50],i;
	for(i = 0; i < c; i++){
		box[i] = card[p + i - 1];
	}
	for(i = 0; i < p; i++){
		card[p - 2 + c - i] = card[p - 2 - i];
	}
	for(i = 0; i < c; i++){
		card[i] = box[i];
	}
}