#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";
}
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgogCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKc3RydWN0IENvbW1hIHsKICAgIGludCBudW0sIHBvczsKICAgIENvbW1hKCkgewogICAgICAgIG51bSA9IDA7CiAgICAgICAgcG9zID0gMDsKICAgIH0KfTsKIAppbnQgbWFpbigpIHsKICAgIGludCBuLCByOwogICAgd2hpbGUoY2luID4+IG4gPj4gcikgewogICAgICAgIGludCBwLCBjOwogICAgICAgIHN0cmluZyBzOwogICAgICAgIC8vIEZpbGxpbmcgdGhlIGFycmF5IHdpdGggY2FyZHMnIG51bWJlcnMgc2VwYXJhdGVkIGJ5IGNvbW1hCiAgICAgICAgZm9yIChpbnQgaSA9IG47IGkgPiAwOyBpLS0pIHMgKz0gKGkgPT0gMSA/IHRvX3N0cmluZygxKSA6IHRvX3N0cmluZyhpKSArICIsIik7CiAgICAgICAgaWYgKG4gPiAwKSB7CiAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgcjsgaSsrKSB7CiAgICAgICAgICAgIAljaW4gPj4gcCA+PiBjOwogICAgICAgICAgICAgICAgLy8gQ3JlYXRlIG9iamVjdCB3aXRoIG51bWJlciBvZiBjb21tYSBpbiBzdHJpbmcgYW5kIGl0cyBwb3NpdGlvbgogICAgICAgICAgICAgICAgQ29tbWEgY29tbWExLCBjb21tYTI7CiAgICAgICAgICAgICAgICBpbnQgc19sZW4gPSBzLmxlbmd0aCgpOwogICAgICAgICAgICAgICAgaWYgKHAgIT0gMSkgewogICAgICAgICAgICAgICAgICAgIC8vIC0tLS0tLS0tIExvb2tpbmcgZm9yIGluZGV4ZXMgb2YgbmVlZGVkIGNvbW1hcyB0byBwaWNrICdjJyBjYXJkcwogICAgICAgICAgICAgICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgc19sZW47IGorKykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY29tbWExLm51bSA9PSBwLTEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1hMS5wb3MgPSBqOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tbWExLm51bSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNvbW1hMi5udW0gPT0gcCtjLTEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1hMi5wb3MgPSBqOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tbWEyLm51bSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNvbW1hMS5wb3MgPT0gMCAmJiBzW2pdID09ICcsJykgY29tbWExLm51bSArPSAxOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY29tbWEyLnBvcyA9PSAwICYmIHNbal0gPT0gJywnKSBjb21tYTIubnVtICs9IDE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIC8vIC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQogCiAKICAgICAgICAgICAgICAgICAgICAvLyAtLS0tLS0tLS0gU3dhcHBpbmcgY2FyZHMgLS0tLS0tLS0tCiAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHMxID0gcy5zdWJzdHIoY29tbWExLnBvcywgY29tbWEyLnBvcyAtIGNvbW1hMS5wb3MpOwogICAgICAgICAgICAgICAgICAgIHMuZXJhc2UoY29tbWExLnBvcywgY29tbWEyLnBvcyAtIGNvbW1hMS5wb3MpOwogICAgICAgICAgICAgICAgICAgIGlmIChzMVtzMS5sZW5ndGgoKS0xXSAhPSAnLCcpIHMgPSBzMSArICcsJyArIHM7CiAgICAgICAgICAgICAgICAgICAgZWxzZSBzID0gczEgKyBzOwogICAgICAgICAgICAgICAgICAgIC8vIC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBpbnQgayA9IDA7CiAgICAgICAgICAgIHdoaWxlIChzW2tdICE9ICcsJykgaysrOwogICAgICAgICAgICBzdHJpbmcgcmVzID0gcy5zdWJzdHIoMCwgayk7CiAgICAgICAgICAgIGNvdXQgPDwgcmVzIDw8ICJcbiI7CiAgICAgICAgfQogICAgfQp9