using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var li = new LinkedLink<int>();
        for(var i = 0; i < num; i++)
        {
            var input = ReadLine().Split(' ');
            var n = 0;
            if(input.Length==2)
            n = int.Parse(input[1]);
            switch (input[0])
            {
                case "insert":
                    li.InsertHead(n);
                    break;
                case "delete":
                    li.Delete(n);
                    break;
                case "deleteFirst":
                    li.DeleteHead();
                    break;
                case "deleteLast":
                    li.DeleteTail();
                    break;
            }
        }
        WriteLine(string.Join(" ", li.ToArray()));
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}

public class LinkedLink<T>
{
    private class Node
    {
        public T Key { get; set; }
        public Node Next { get; set; }
        public Node Prev { get; set; }

        public Node() : this(default(T), null, null)
        {

        }

        public Node(T Key, Node Next, Node Prev)
        {
            this.Key = Key;
            this.Next = Next;
            this.Prev = Prev;
        }
    }
    private Node head;
    private Node tail;
    private readonly Node NIL;
   

    public int Size { get; private set; }

    public T Head { get { return head.Key; } }

    public T Tail { get { return tail.Key; } }


    public LinkedLink()
    {
        NIL = new Node();
        head = NIL;
        tail = NIL;
        Size = 0;
    }

    private Node Search(T value)
    {
        var node = head;
        while (!ReferenceEquals(node, NIL) && !node.Key.Equals(value))
            node = node.Next;
        return node;
    }

    private bool Init(Node node)
    {
        if (Size == 1)
        {
            head = node;
            tail = node;
        }
        return Size == 1;
    }

    public void InsertHead(T value)
    {
        Size++;
        var node = new Node(value, head, NIL);
        if (!ReferenceEquals(head, NIL)) head.Prev = node;
        head = node;
        Init(node);
    }

    public void InsertTail(T value)
    {
        Size++;
        var node = new Node(value, NIL, tail);
        if (!ReferenceEquals(tail, NIL)) tail.Next = node;
        tail = node;
        Init(node);
    }

    public void Delete(T value)
    {
        var node = Search(value);
        if (ReferenceEquals(node, NIL))
            return;
        Size--;
        if (!ReferenceEquals(node.Prev, NIL))
            node.Prev.Next = node.Next;
        else head = node.Next;
        if (!ReferenceEquals(node.Next, NIL))
            node.Next.Prev = node.Prev;
        else tail = node.Prev;
        if (Size == 0)
        {
            head = NIL;
            tail = NIL;
        }
    }

    public void DeleteHead()
    {
        if (ReferenceEquals(head, NIL))
            throw new NullReferenceException("要素が存在しません");
        Size--;
        head.Next.Prev = NIL;
        head = head.Next;
        if (Size == 0) tail = NIL;
    }

    public void DeleteTail()
    {
        if (ReferenceEquals(tail, NIL))
            throw new NullReferenceException("要素が存在しません");
        Size--;
        tail.Prev.Next = NIL;
        tail = tail.Prev;
        if (Size == 0) head = NIL;
    }

    public T[] ToArray()
    {
        var item = new T[this.Size];
        var node = head;
        var index = 0;
        while (!ReferenceEquals(node, NIL))
        {
            item[index] = node.Key;
            node = node.Next;
            index++;
        }
        return item;
    }
    

}


Measured memory_bytes: 69832