#include<stdio.h>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <functional>
#include <stdio.h>
#include <array>
#include <algorithm>
#include <string>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <queue>
#include<iomanip>
#include<bitset>
#include<stack>
#include<set>
#include<limits>
#include <complex>
using namespace std;

int dx[7] = { -1,0,1,0,-1,0,1 };
int dy[7] = { 0,1,0,-1,0,1,0 };

bool memo[64][16][4][64][16][4];


vector <vector<bool>>mp;

struct aa {
	int fx;
	int fy;
	int fway;
	int tx;
	int ty;
	int tway;
};
int gx, gy;

vector<aa>astack;

bool cangoal;

int gway;

bool check(int fx, int fy,int fway, int tx, int ty, int tway) {

	if (memo[fx][fy][fway][tx][ty][tway])return false;
	memo[fx][fy][fway][tx][ty][tway] =true;
	
	//else{

		int nfy = fy + dy[fway];
		int nfx = fx + dx[fway];
		while (1) {
			
			if (mp[nfy][nfx]) {
				nfx -= dx[fway];
				nfy -= dy[fway];
				break;
			}
			nfy = nfy + dy[fway];
			nfx = nfx + dx[fway];

		}

		int nty = ty;
		int ntx = tx;
		while (1) {

			if (mp[nty][ntx]) {
				ntx -= dx[tway];
				nty -= dy[tway];
				break;
			}

			if (mp[nty + dy[tway + 1]][ntx + dx[tway + 1]]) {
				int afway = (fway + 3) % 4;
				int atway = (tway + 3) % 4;
				if (nfx == gx&&nfy == gy&&ntx == gx&&nty == gy) {
					if (tway == (gway + 2) % 4)
						return true;
				}
				if (fx == gx&&fy == gy) {
					cangoal = true;
				}
				if (!memo[nfx][nfy][afway][ntx][nty][atway]) {
					astack.push_back(aa{ nfx,nfy,afway,ntx,nty,atway });
				}
			}

			if (mp[nty + dy[tway + 3]][ntx + dx[tway + 3]]) {
				int afway = (fway + 1) % 4;
				int atway = (tway + 1) % 4;
				if (nfx == gx&&nfy == gy&&ntx == gx&&nty == gy) {
					if (tway == (gway + 2) % 4)
						return true;
				}
				if (fx == gx&&fy == gy) {
					cangoal = true;
				}
				if (!memo[nfx][nfy][afway][ntx][nty][atway]) {
					astack.push_back(aa{ nfx,nfy,afway,ntx,nty,atway });
				}
			}

			nty = nty + dy[tway];
			ntx = ntx + dx[tway];
		}
		if (mp[nty + dy[tway + 1]][ntx + dx[tway + 1]]) {
			int afway = (fway + 3) % 4;
			int atway = (tway + 3) % 4;
			if (nfx == gx&&nfy == gy&&ntx == gx&&nty == gy) {
				if (tway == (gway + 2) % 4)
					return true;
			}
			if (fx == gx&&fy == gy) {
				cangoal = true;
			}
			if (!memo[nfx][nfy][afway][ntx][nty][atway]) {
				
				astack.push_back(aa{ nfx,nfy,afway,ntx,nty,atway });
			}
		}

		if (mp[nty + dy[tway + 3]][ntx + dx[tway + 3]]) {
			int atway = (tway + 1) % 4;
			int afway = (fway + 1) % 4;
			if (nfx == gx&&nfy == gy&&ntx == gx&&nty == gy) {
				if (tway == (gway + 2) % 4)
					return true;
			}
			if (fx == gx&&fy == gy) {
				cangoal = true;
			}
			if (!memo[nfx][nfy][afway][ntx][nty][atway]) {	
				astack.push_back(aa{ nfx,nfy,afway,ntx,nty,atway });

			}
		}

	//}
	return false;
}

bool memo2[64][16][4];

bool check2(int fx, int fy, int fway) {
	if (memo2[fx][fy][fway])return false;
	memo2[fx][fy][fway] = true;

	if (fx == gx&&fy == gy)return true;
	int nfy = fy + dy[fway];
	int nfx = fx + dx[fway];
	while (1) {

		if (mp[nfy][nfx]) {
			nfy -= dy[fway];
			nfx -= dx[fway];
			break;
		}
		nfy = nfy + dy[fway];
		nfx = nfx + dx[fway];
	}
	return (check2(nfx, nfy, (fway + 1) % 4) || check2(nfx, nfy, (fway + 3) % 4));
}

int main() {
	while (1) {
		int n, r; cin >> n >> r;
		if (!n)break;
		vector<int>ya(n);
		for (int i = 0; i < n; ++i) {
			ya[i] = n-(i);
		}
		for (int i = 0; i < r; ++i) {
			int p, c; cin >> p >> c;
			vector<int>nya(ya);
			for (int i = 0; i < c; ++i) {
				nya[i] = ya[p-1 + i];
			}
			for (int i =c; i < c+p-1; ++i) {
				nya[i] = ya[i-c];
			}
			ya = nya;
		}
		cout << ya[0] << endl;
	}

	return 0;
}

Measured memory_bytes: 3064