R(n,r){
	int p,c,t;
	if(r){
		scanf("%d%d",&p,&c);
		t=R(n,r-1);
		if(t>n-c)
			t-=p-1;
		else if(t>n-c-(p-1))
			t+=c;
		return t;
	}else{
		return n;
	}
}
main(){
	int n,r;
	for(;scanf("%d%d",&n,&r),n;){
		printf("%d\n",R(n,r));
	}
	exit(0);
}