#include <iostream>
#include <string>
 
using namespace std;
 
struct Comma {
    int num, pos;
    Comma() {
        num = 0;
        pos = 0;
    }
};
 
int main() {
    int n, r;
    while(cin >> n >> r) {
        int p, c;
        string s;
        // Filling the array with cards' numbers separated by comma
        for (int i = n; i > 0; i--) s += (i == 1 ? to_string(1) : to_string(i) + ",");
        if (n > 0) {
            for (int i = 0; i < r; i++) {
            	cin >> p >> c;
                // Create object with number of comma in string and its position
                Comma comma1, comma2;
                int s_len = s.length();
                if (p != 1) {
                    // -------- Looking for indexes of needed commas to pick 'c' cards
                    for (int j = 0; j < s_len; j++) {
                        if (comma1.num == p-1) {
                            comma1.pos = j;
                            comma1.num = 0;
                        }
                        if (comma2.num == p+c-1) {
                            comma2.pos = j;
                            comma2.num = 0;
                        }
                        if (comma1.pos == 0 && s[j] == ',') comma1.num += 1;
                        if (comma2.pos == 0 && s[j] == ',') comma2.num += 1;
                    }
                    // ---------------------------------------------------------------
 
 
                    // --------- Swapping cards ---------
                    string s1 = s.substr(comma1.pos, comma2.pos - comma1.pos);
                    s.erase(comma1.pos, comma2.pos - comma1.pos);
                    if (s1[s1.length()-1] != ',') s = s1 + ',' + s;
                    else s = s1 + s;
                    // ----------------------------------
                }
            }
            int k = 0;
            while (s[k] != ',') k++;
            string res = s.substr(0, k);
            cout << res << "\n";
        }
    }
}