#include <iostream>
#include <vector>
using namespace std;
struct node* head = NULL;
struct node {
    int data;
    struct node* next;
};

struct node* list() {
    struct node* head = (struct node*)malloc(sizeof(struct node));
    head -> next == NULL;
    return head;
}

void Insert(int x, int y) {
    struct node* curNode = head -> next;
    struct node* preNode = head;
    struct node* newNode = (struct node*)malloc(sizeof(struct node));
    newNode -> data = y;
    newNode -> next = NULL;
    while (curNode != NULL) {
        if (curNode -> data == x) {
            preNode -> next = newNode;
            newNode -> next = curNode;
            return;
        }
        preNode = curNode;
        curNode = curNode -> next;
    }
    preNode -> next = newNode;

}

void Delete(int val) {
    struct node* curNode = head -> next;
    struct node* preNode = head;
    while (curNode != NULL) {
//         cout << curNode -> data << preNode -> data << " ";
        if (curNode -> data == val) {
            preNode -> next = curNode -> next;
            return;
        }
        preNode = curNode;
        curNode = curNode -> next;
    }
}

void printList() {
    struct node* curNode = head -> next;
    if (curNode == NULL) {
        cout << "NULL";
        return;
    } 
    while (curNode != NULL) {
        cout << curNode -> data << " ";
        curNode = curNode -> next;
    }
}
vector<string> split(string str, string cat) {
    vector<string> res;
    int t ;
    while ((t = str.find(cat)) > 0) {
        res.push_back(str.substr(0, t));
        str.erase(0, t + 1);
    }
    if (str.size() != 0) res.push_back(str);
    return res;
}

int main() {
    head = list();
    int n;
    cin >> n;
    getchar();
    string s;
    for (int i = 0; i < n; i++) {
        getline(cin, s);
        auto res = split(s, " ");
        if (res[0] == "insert") {
            Insert(atoi(res[1].c_str()), atoi(res[2].c_str()));
        } else {
            Delete(atoi(res[1].c_str()));
        }
//         printList();
//         cout << "\n";
    }
    printList();
    return 0;
}