#include <bits/stdc++.h>
using namespace std;
int s;
deque<int> dq;
int main() {
cin >> s;
int counter = 1;
while(s--) {
char c; cin >> c;
char x; cin >> x;
if(c == 'A') {
counter++;
if(x == 'L') dq.push_front(counter);
else dq.push_back(counter);
} else {
int k; cin >> k;
for(int i = 1; i <= k; i++) {
if(x == 'L') dq.pop_front();
else dq.pop_back();
}
}
}
while(!dq.empty()) {
cout << dq.front() << "\n";
dq.pop_front();
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IHM7CmRlcXVlPGludD4gZHE7CgppbnQgbWFpbigpIHsKICAgIGNpbiA+PiBzOwogICAgaW50IGNvdW50ZXIgPSAxOwogICAgd2hpbGUocy0tKSB7CiAgICAgICAgY2hhciBjOyBjaW4gPj4gYzsKICAgICAgICBjaGFyIHg7IGNpbiA+PiB4OwogICAgICAgIGlmKGMgPT0gJ0EnKSB7CiAgICAgICAgICAgY291bnRlcisrOwogICAgICAgICAgIGlmKHggPT0gJ0wnKSBkcS5wdXNoX2Zyb250KGNvdW50ZXIpOwogICAgICAgICAgIGVsc2UgZHEucHVzaF9iYWNrKGNvdW50ZXIpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGludCBrOyBjaW4gPj4gazsKICAgICAgICAgICAgZm9yKGludCBpID0gMTsgaSA8PSBrOyBpKyspIHsKICAgICAgICAgICAgICAgIGlmKHggPT0gJ0wnKSBkcS5wb3BfZnJvbnQoKTsKICAgICAgICAgICAgICAgIGVsc2UgZHEucG9wX2JhY2soKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIHdoaWxlKCFkcS5lbXB0eSgpKSB7CiAgICAgICAgY291dCA8PCBkcS5mcm9udCgpIDw8ICJcbiI7CiAgICAgICAgZHEucG9wX2Zyb250KCk7CiAgICB9Cn0=