#include <stdio.h>
#include <string.h>

void shuffle(int p,int c,int card[]){
	
	int d[50],i;
	memcpy(d,card,50*sizeof(int));
	
	for(i = 0;i < c;i++){
		d[i] = card[p + i];
	}
	
	for(i = 0; i< p - 1;i++){
		d[c + i] = card[i];
	}
	
	memcpy(card,d,50*sizeof(int));
	
}
int main(void){
	int i,n,r,p,c,card[50];
	
	while(1){
		scanf("%d %d",&n,&r);
			if(n == 0 && r == 0) break;
		for(i = 0;i < r;i++){
			scanf("%d %d",&p,&c);
			shuffle(p,c,card);
			
		}
		printf("%d\n",(n - card[0]));
	}
	return 0;
}