#include #include #include using namespace std; int main(){ int n, r; while(cin >> n >> r){ vector cards; if(n == 0 && r == 0){ break; } int p, q; for(int i = 0; i < n; i++){ cards.push_back(n - i); } for(int i = 0; i < r; i++){ cin >> p >> q; p--; vector temp, temp2; for(int i = 0 ;i < p; i++){ temp.push_back(cards[i]); } for(int i = p; i < p + q; i++){ temp2.push_back(cards[i]); } for(int i = 0; i < q; i++){ cards[i] = temp2[i]; } for(int i = 0; i < p; i++){ cards[q + i] = temp[i]; } } cout << cards[0] << endl; } return 0; }