#include <cstdio>
#include <cstdint>
#include <map>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cstddef>
#include <cctype>
#include <iomanip>
#include <iostream>
#include <tuple>
#include <utility>
#include <math.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };



/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

struct Node {
    int key;
    Node * next;
    Node * prev;
};

Node * nil;

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

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

Node * serachNode(int key) {
    Node * node = nil->next;
    while (node != nil && node -> key != key) {
        node = node -> next;
    }
    return node;
}

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

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

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

void deleteKey(int key) {
    deleteNode(serachNode(key));
}

void print() {
    Node * node = nil -> next;
    int cnt = 0;
    while(node != nil) {
        if(cnt) printf(" ");
        printf("%d", node->key);
        node = node -> next;
        ++cnt;
    }
    printf("\n");
}

int main() {

    int n;
    scanf("%d", &n);
    init();

    for(int i=0; i<n; ++i) {
        char s[20];
        scanf("%s", s);
        if(strcmp(s, "deleteFirst") == 0) { deleteFirst(); }
        if(strcmp(s, "deleteLast") == 0) { deleteLast(); }
        if(strcmp(s, "insert") == 0) {
            int x;
            scanf("%d", &x);
            insert(x);
        }
        if(strcmp(s, "delete") == 0) {
            int x;
            scanf("%d", &x);
            deleteKey(x);
        }
    }

    print();
}



Measured memory_bytes: 34392