using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AOJ
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var llst = new MyLinkedList();
            var dctx = new Dictionary<string, Action<int>>();
            var dct = new Dictionary<string, Action>();
            dctx["insert"] = (x) => llst.insert(x);
            dctx["delete"] = (x) => llst.delete(x);
            dct["deleteFirst"] = () => llst.deleteFirst();
            dct["deleteLast"] = () => llst.deleteLast();

            for(var i =0;i<N;++i)
            {
                var cmm = ReadLine().Split();
                if (cmm.Length==2)
                { dctx[cmm[0]](int.Parse(cmm[1])); }
                else
                { dct[cmm[0]](); }
            }
            var lst = new List<int>();
            foreach (var n in llst)
            { lst.Add(n); }
            WriteLine(string.Join(" ", lst));
        }
        public class MyLinkedList
        {
            class MyLinkedNode
            {
                public MyLinkedNode(int key) { this.Key = key; }
                public int Key;
                public MyLinkedNode prev, next;
            }

            MyLinkedNode b, e;
            int nodenum = 0;
            public IEnumerator<int> GetEnumerator()
            {
                for (var n = b; n != null; n = n.next)
                    yield return n.Key;
            }
            public MyLinkedList() { }
            public void insert(int key)
            {
                var n = new MyLinkedNode(key);
                if (0 == nodenum)
                { b = e = n; }
                else
                {
                    b.prev = n;
                    b.prev.next = b;
                    b = n;
                }
                ++nodenum;
            }
            public void delete(int key)
            {
                var n = b;
                while (n != null && n.Key != key)
                { n = n.next; }
                if (n == null)
                { return; }
                if (n.prev != null)
                { n.prev.next = n.next; }
                else
                { b = n.next; }
                if (n.next != null)
                { n.next.prev = n.prev; }
                else
                { e = n.prev; }
                b.prev = null;
                e.next = null;
                --nodenum;
            }
            public void deleteFirst()
            {
                if (nodenum <= 1)
                {
                    b = e = null;
                    nodenum = 0;
                }
                else
                {
                    b = b.next;
                    b.prev = null;
                    --nodenum;
                }
            }
            public void deleteLast()
            {
                if(nodenum<=1)
                {
                    b = e = null;
                    nodenum = 0;
                }
                else
                {
                    e = e.prev;
                    e.next = null;
                    --nodenum;
                }
            }
        }
    }
}




Measured memory_bytes: 71656