include [HTML_REMOVED]
using namespace std;
const int N = 100010;
// 分别表示头指针 链表的值 指针的指向 当前的位置
int head, e[N], r[N], l[N], idx;
void init()
{
r[0] = 1, r[1] = -1;
l[0] = -1, l[1] = 0;
idx = 2;
}
void add(int k, int x)
{
e[idx] = x;
r[idx] = r[k], l[idx] = k;
l[r[k]] = idx, r[k] = idx;
idx++;
}
void remove(int k)
{
r[l[k]] = r[k], l[r[k]] = l[k];
}
int main(int argc, const char **argv)
{
int k, x, m;
cin >> m;
init();
char op[5];
while (m–)
{
cin >> op;
if (op[0] == ‘L’)
{
cin >> x;
add(0, x);
}
else if (op[0] == ‘R’)
{
cin >> x;
add(l[1], x);
}
else if (op[0] == ‘D’)
{
cin >> k;
remove(k + 1);
}
else
{
if (op[1] == ‘L’)
{
cin >> k >> x;
add(l[k + 1], x);
}
else
{
cin >> k >> x;
add(k + 1, x);
}
}
}
for (int i = r[0]; i != 1; i = r[i])
cout << e[i] << ” “;
return 0;
}