import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


// ???????????????????????¨?????????
class Node{
    int value;
    Node prev;
    Node next;

    Node(){

    }

    Node(int value){
        this.value = value;
    }
}

public class Main {

    static Node head;

    // ????§?????????¨??????????????????????????¨
    private static void init(){
        head = new Node();
        head.next = head;
        head.prev = head;
    }

    // ??¨?????¨?????´????????????
    public static void insert(int x){

        Node temp = new Node(x);
        temp.next = head.next;
        temp.prev = head;
        head.next = temp;
        temp.next.prev = temp;
    }

    //?????¨??????????????\?????°delete????????????????????°???????????¶????????????
    public static void delete(int x){

        deleteNode(listSearch(x));
    }

    public static Node listSearch(int x){
        Node cur = head.next;
        while (cur != head && cur.value != x){
            cur = cur.next;
        }
        return cur; // ??????????????????????????°?????????,?¢??????´????°??????????????´??????¨?????¨???
    }

    public static void deleteNode(Node node){

        if (node == head){
            return;
        }

        node.prev.next = node.next;
        node.next.prev = node.prev;

        // ?°?node????????¨?????????null?????\????????\?°?????????¶
        node.prev = null;
        node.next = null;
    }

    public static void deleteFirst(){
        deleteNode(head.next);
    }

    public static void deleteLast(){
        deleteNode(head.prev);
    }

    // ?????°?????¨????´????????????¨??????????????¢??????????¢?
    private static void printList() {
        int count = 0;
        Node cur = head.next;
        while (cur != head){
            if (count++ > 0){
                System.out.print(" ");
            }
            System.out.print(cur.value);
            cur = cur.next;
        }

        // ?????????????????¢??????????????\???????????????????¢?
        System.out.println();
    }

    public static void main(String[] args) throws IOException {

        init();

//        Scanner sc = new Scanner(System.in);
//        int n = sc.nextInt();
//
//        for (int i=0; i<n; i++){
//            String str = sc.next();
//            // equals????¶???¶
//            if (str.charAt(0) == 'i'){
//                int key = sc.nextInt();
//                insert(key);
//            }else if (str.length() > 6){
//                if (str.charAt(6) == 'F') {
//                    deleteFirst();
//                }else {
//                    deleteLast();
//                }
//            } else {
//                int key = sc.nextInt();
//                delete(key);
//            }
//        }

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        for (int i=0; i<n; i++){
            String str = br.readLine();
            if (str.charAt(0) == 'i'){
                int key = Integer.parseInt(str.substring(7));
                insert(key);
            } else if (str.charAt(6) == 'F'){
                deleteFirst();
            } else if (str.charAt(6) == 'L'){
                deleteLast();
            } else {
                int key = Integer.parseInt(str.substring(7));
                delete(key);
            }
        }

        printList();
    }

}

Measured memory_bytes: 124564