1 #include <cstdio>
2 #include <cstring>
3 #include <cmath>
4 #include <string>
5 #include <iostream>
6 #include <algorithm>
7 #include <queue>
8 using namespace std;
9 #define rep(i, n) for(int i=0; i<(n); ++i)
10 #define for1(i,a,n) for(int i=(a);i<=(n);++i)
11 #define for2(i,a,n) for(int i=(a);i<(n);++i)
12 #define for3(i,a,n) for(int i=(a);i>=(n);--i)
13 #define for4(i,a,n) for(int i=(a);i>(n);--i)
14 #define CC(i,a) memset(i,a,sizeof(i))
15 #define read(a) a=getint()
16 #define print(a) printf("%d", a)
17 #define dbg(x) cout << #x << " = " << x << endl
18 #define printarr(a, n, m) rep(aaa, n) { rep(bbb, m) cout << a[aaa][bbb]; cout << endl; }
19 inline const int getint() { int r=0, k=1; char c=getchar(); for(; c<‘0‘||c>‘9‘; c=getchar()) if(c==‘-‘) k=-1; for(; c>=‘0‘&&c<=‘9‘; c=getchar()) r=r*10+c-‘0‘; return k*r; }
20 inline const int max(const int &a, const int &b) { return a>b?a:b; }
21 inline const int min(const int &a, const int &b) { return a<b?a:b; }
22
23 const int N=100005;
24 int q[N], n, front, tail;
25
26 inline void fix(int &x) { if(x<0) x=N+x; if(x>=N) x-=N; }
27 int main() {
28 read(n);
29 int cnt=0;
30 for1(i, 1, n) {
31 char ch=getchar(); while(ch<‘A‘||ch>‘Z‘) ch=getchar();
32 if(ch==‘A‘) {
33 ch=getchar(); while(ch<‘A‘||ch>‘Z‘) ch=getchar();
34 if(ch==‘L‘) { --front; fix(front); q[front]=++cnt; }
35 else if(ch==‘R‘) q[tail++]=++cnt, fix(tail);
36 }
37 else if(ch==‘D‘) {
38 ch=getchar(); while(ch<‘A‘||ch>‘Z‘) ch=getchar();
39 int t=getint();
40 if(ch==‘L‘) front+=t, fix(front);
41 else if(ch==‘R‘) tail-=t, fix(tail);
42 }
43 }
44 while(front!=tail) {
45 printf("%d\n", q[front++]); fix(front);
46 }
47 return 0;
48 }