#include<bits/stdc++.h>
using namespace std;
struct Node
{
int data;
Node *next;
};
int main()
{
int n,x,y;
char operate[10];
Node head,*ptr,*ptr2;
head.data =1;
head.next=NULL;
ptr=&head;
ptr2=&head;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%s",operate);
if(operate[0]=='a')
{
scanf("%d%d",&x,&y);
while(ptr!=NULL)
{
if(ptr->data==x)
{
ptr2=ptr->next;
ptr->next=(Node*)malloc(sizeof(Node));
ptr=ptr->next;
ptr->data=y;
ptr->next=ptr2;
break;
}
else ptr=ptr->next;
}
}
else
{
scanf("%d",&x);
while(ptr!=NULL)
{
if(ptr->data==x)
{
ptr2=ptr->next;
ptr->next=ptr->next->next;
free(ptr2);
ptr2=NULL;
break;
}
else ptr=ptr->next;
}
}
ptr=&head;
}
while(ptr->next!=NULL)
{
printf("%d ",ptr->data);
ptr=ptr->next;
}
printf("%d ",ptr->data);
return 0;
}