#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<stack>
char Pre[70];
char Mid[70];
typedef struct TNode* BinTree;
typedef BinTree Position;
struct TNode {
int Data;
Position Left;
Position Right;
};
void AfT(BinTree T);
BinTree BuildBinTree(int PreStart, int MidStart, int NodeNum);
using namespace std;
int NUM = 0;
int N;
int main()
{
scanf("%d", &N);
char str[5];
stack<int>stack;
int k = 0;
int j = 0;
int num;
for (int i = 0; i < 2*N; i++)
{
scanf("%s", str);
if (str[1] == 'u')
{
scanf("%d", &num);
stack.push(num);
Pre[k++] = num;
}
else
{
Mid[j++] = stack.top();
stack.pop();
}
}
BinTree T = BuildBinTree(0, 0, N);
AfT(T);
}
BinTree BuildBinTree(int PreStart, int MidStart, int NodeNum)
{
BinTree Tree = (BinTree)malloc(sizeof(struct TNode));
Tree->Data = Pre[PreStart];
Tree->Left = NULL;
Tree->Right = NULL;
if (NodeNum > 1)
{
int i;
for (i = 0; i < NodeNum; i++)
{
if (Mid[MidStart + i] == Pre[PreStart])
{
break;
}
}
if (i > 0)
{
Tree->Left = BuildBinTree(PreStart + 1, MidStart, i);
}
if (i < NodeNum - 1)
{
Tree->Right = BuildBinTree(PreStart + i + 1, MidStart + i + 1, NodeNum - i - 1);
}
}
return Tree;
}
void AfT(BinTree T)
{
if (T)
{
AfT(T->Left);
AfT(T->Right);
if (NUM < N - 1)
{
printf("%d ", T->Data);
NUM++;
}
else
{
printf("%d", T->Data);
}
}
}