#include <math.h>
#include <stdio.h>
#include<stdlib.h>
typedef struct listN * Node;
struct listN
{
    int data;
    Node P;
};
Node initList(void);
void insert(Node L, int x, int y);
void delet(Node L, int x);
int main(void) 
{
    int n, x, y, i, ret;
    char op[6];
    scanf("%d",&n);
    Node L, Ptr;
    L = initList();
    for(i = 0; i<n;i++)
    {
       
        ret = scanf("%s %d %d",op,&x,&y);
        if(ret == 3)
        {
            insert(L,x,y);
        }
        else 
        {
            delet(L,x);
        }
    }
    Ptr = L;
    if(Ptr->P == NULL)
    {
        printf("NULL");
    }
    while(Ptr->P)
    {
        Ptr = Ptr->P;
        printf("%d ",Ptr->data);
    }
    return 0;
}
Node initList(void)
{
    Node L;
    L = (Node)malloc(sizeof(struct listN));
    L->data = INFINITY;
    L->P = NULL;
    return L;
}
void insert(Node L, int x, int y)
{
    Node Ptr, NewNode;
    int flag = 0;
    
    for(Ptr = L;Ptr->P != NULL;Ptr = Ptr->P)
    {
        if(Ptr->P->data == x)
        {
            NewNode = (Node)malloc(sizeof(struct listN));
            NewNode->data = y;
            NewNode->P = Ptr->P;
            Ptr->P = NewNode;
            flag = 1;
            break;
        }
    }
    if(flag == 0)
    {
        NewNode = (Node)malloc(sizeof(struct listN));
        NewNode->data = y;
        NewNode->P = NULL;
        Ptr->P = NewNode;
    }
}
void delet(Node L, int x)
{
    Node Ptr, temp;
    for(Ptr = L; Ptr->P != NULL;Ptr = Ptr->P)
    {
        if(Ptr->P->data == x)
        {
            temp = Ptr->P;
            Ptr->P = Ptr->P->P;
            temp->P = NULL;
            free(temp);
            break;
        }
    }
}