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

typedef struct Node {
    long key;
    struct Node *prev, *next;
} Node;

Node *nil;

void init() {
    nil = (Node *)malloc(sizeof(Node));
    nil->prev = nil;
    nil->next = nil;
}

void insert(long key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

Node* linearSearch(long key) {
    Node *p;
    for (p = nil->next; p != nil; p = p->next)
        if (p->key == key) return p;
    return nil;
}

void deleteNode(Node *p) {
    if (p == nil) return;
    p->prev->next = p->next;
    p->next->prev = p->prev;
    free(p);
}

void deleteKey(long key) {
    deleteNode(linearSearch(key));
}


void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void printList() {
    Node *p;
    int i = 0;
    for (p = nil->next; p != nil; p = p->next) {
        if (i++) printf(" ");
        printf("%ld", p->key);
    }
    printf("\n");
}



int main() {

    int n;
    long key;
    char s[12];
    init();
    scanf("%d", &n);
    for (int i = 0 ; i < n; i++) {
        scanf("%s%ld", s, &key);
        if (s[0] == 'i') insert(key);
        else if (strlen(s) > 6) {
            if (s[6] == 'F') deleteFirst();
            else if (s[6] == 'L') deleteLast();
        }
        else deleteKey(key);
    }
    printList();

    return 0;
}
