#include<stdio.h>
int p[55],c[55];
int main(){
	int i,j,n,r,x;
	while(1){
		scanf("%d%d",&n,&r);
		if(n==0)break;
		for(i=0;i<r;i++)scanf("%d%d",&p[i],&c[i]);
		x=1;
		for(i=r-1;i>=0;i--){
			if(x<=c[i]){
				x=p[i]+x-1;
			}else if(c[i]<x && x<c[i]+p[i]){
				x-=c[i];
			}
			//printf(" %d\n",x);
		}
		printf("%d\n",n-x+1);
	}
	return 0;
}