#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <stack>
using namespace std;
struct Node{
int key;
int left, right;
}node[50];
int porder[50], pn = 0;
int iorder[50], in = 0;
int N, num = 0;
int creat(int pL, int pR, int inL, int inR){
if(pL > pR) return -1;
int addr = num;
node[addr].key = porder[pL];
num++;
int p = inL;
for( ; p <= inR; p++){
if(iorder[p] == porder[pL]) break;
}
int n1 = p - inL;
node[addr].left = creat(pL+1, pL+n1, inL, p-1);
node[addr].right = creat(pL+n1+1, pR, p+1, inR);
return addr;
}
int cnt = 1;
void postOrder(int index){
if(index == -1) return;
postOrder(node[index].left);
postOrder(node[index].right);
printf("%d", node[index].key);
if(cnt < N) putchar(' ');
cnt++;
}
int main(){
scanf("%d", &N);
string ope;
int x;
stack<int> st;
for(int i = 0; i < 2*N; i++){
cin >> ope;;
if(ope == "Push"){
cin >> x;
porder[pn++] = x;
st.push(x);
}else{
iorder[in++] = st.top();
st.pop();
}
}
int first = creat(0, N-1, 0, N-1);
postOrder(first);
return 0;
}