#include using namespace std; int main() { int n, r; while(cin >> n >> r) { if(n == 0 && r == 0) break; int array[n + 1]; for(int i = 0; i < n; i++) array[i + 1] = n - i; while(r--) { int a, b; cin >> a >> b; int tmp[n + 1]; for(int i = a ; i<= b + a; i++) tmp[i] = array[i]; for(int i = a - 1; i >= 1; i--) array[i + b] = array[i]; for(int i = 1; i <= b; i++) array[i] = tmp[i + a - 1]; } cout << array[1] << endl; } return 0; }