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

void shuffle(int p,int c,int n[]){
	int tmp[50] = {0},i;
	memcpy(tmp,n,sizeof(int)*50);
	
	for(i = 0;i < c;i++){
		tmp[i] = n[p - 1 + i];
	}
	for(i = c;i < c + p -1;i++){
		tmp[i] = n[i - c];
	}
	memcpy(n,tmp,sizeof(int)*50);
	return;
}

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