#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct node {
    int data;
    struct node* next;
} Linklist;

Linklist* head;
void InitLinklist() {
    head = (Linklist*)malloc(sizeof(Linklist));
    head->next = NULL;
}

int insert(Linklist* head, int x, int y) {
    Linklist* P = head->next;
    Linklist* Pre = head;
    Linklist* PN;
    while (P != NULL && P->data != x) {
        Pre = P;
        P = P->next;
    }
    PN = (Linklist*)malloc(sizeof(Linklist));
    PN->data = y;
    PN->next = P;
    Pre->next = PN;
    return 0;
}

int delete (Linklist* head, int x) {
    Linklist* P = head->next;
    Linklist* Pre = head;
    while (P != NULL && P->data != x) {
        Pre = P;
        P = P->next;
    }
    if (P == NULL) {
        return 0;
    } else {
        Pre->next = P->next;
        free(P);
        return 1;
    }
}

int main() {
    int n, x, y;
    char str[10];

    InitLinklist();
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%s", str);
        if (strcmp(str, "insert") == 0) {
            scanf("%d%d", &x, &y);
            insert(head, x, y);
        } else {
            scanf("%d", &x);
            delete (head, x);
        }
    }

    // 输出链表的值
    Linklist* P = head->next;
    if (head->next == NULL) {
        printf("NULL");
    } else {
        while (P != NULL) {
            printf("%d ", P->data);
            P = P->next;
        }
    }
    return 0;
}