#include <stdio.h>

int deck[51];
int tmp[51];

void resetdeck(int deck[]) {
	int i;
	for(i = 0; i < 51; i++ ) {	
		deck[i] = i;
	}
}

int main(void) {
	int i, n, r, p, c, j;
	while(scanf("%d%d",&n,&r),n+r) {
		resetdeck(deck);
		for(i = 0; i < r; i++ ) {
			scanf("%d%d",&p,&c);
			for(j = 0; j < c; j++ ) {
				tmp[j] = deck[n-p-c+2+j];
				deck[n-p-c+2+j] = 0;
			}
			for(j = 1; j <= n; j++ ) {
				if(!deck[j]) {
					deck[j] = deck[j+1];
					deck[j+1] = 0;
				}
			}
			for(j = 0; j < c; j++ ) {
				deck[n - c + 1 + j] = tmp[j];
			}
		}
		printf("%d\n",deck[n]);
	}
	return 0;
}