using LIB;
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    public static IO IO = new IO();
    static void Main(string[] args)
    {
        int n = IO.INT();
        LINKEDLIST<string> l = new LINKEDLIST<string>();
        for (int i = 0; i < n; i++)
        {
            string[] b = IO.STRING().Split(' ');
            switch (b[0])
            {
                case "insert":
                    l.ADDFIRST(b[1]);
                    break;
                case "delete":
                    l.DELETE(b[1]);
                    break;
                case "deleteFirst":
                    l.DELETEFIRST();
                    break;
                case "deleteLast":
                    l.DELETELAST();
                    break;
            }
        }
        IO.WRITE(l.TOARRAYTEXT());
        IO.FLUSH();
    }
}

#region LINKEDLIST
namespace LIB
{
    public class LINKEDLIST<T> where T : IComparable
    {
        private class NODE { public T v; public NODE p, n; }
        private int c;
        private NODE n;
        public LINKEDLIST() { n = new NODE(); CLEAR(); }
        public void CLEAR() { n.n = n; n.p = n; c = 0; }
        public bool CONTAINS(T v) { return (SEARCH(v) != null); }
        public int COUNT() { return c; }
        public void ADDLAST(T v) { NODE a = new NODE(); a.v = v; ADDBEFORE(n, a); }
        public void ADDFIRST(T v) { NODE a = new NODE(); a.v = v; ADDAFTER(n, a); }
        public void ADDBEFORE(T t, T v) { NODE a = new NODE(); a.v = v; ADDBEFORE(SEARCH(t), a); }
        public void ADDAFTER(T t, T v) { NODE a = new NODE(); a.v = v; ADDAFTER(SEARCH(t), a); }
        public void DELETE(T v) { DELETE(SEARCH(v)); }
        public void DELETEFIRST() { DELETE(n.n); }
        public void DELETELAST() { DELETE(n.p); }
        public T FIRST() { return n.n.v; }
        public T LAST() { return n.p.v; }
        public T[] TOARRAY() { T[] r = new T[c]; NODE b = n.n; for (int i = 0; i < c; i++) { r[i] = b.v; b = b.n; } return r; }
        public string TOARRAYTEXT() { StringBuilder s = new StringBuilder(); NODE b = n.n; for (int i = 0; i < c; i++) { s.Append(b.v); if (i < c - 1) { s.Append(' '); } b = b.n; } return s.ToString(); }
        private NODE SEARCH(T v) { NODE r = null; NODE b = n.n; while (b != n) { if (b.v.CompareTo(v) == 0) { r = b; break; } b = b.n; } return r; }
        private void DELETE(NODE t) { if (t != n && t != null) { t.n.p = t.p; t.p.n = t.n; c--; } }
        private void ADDBEFORE(NODE m, NODE t) { NODE b = m.p; t.p = b; t.n = m; m.p = t; b.n = t; c++; }
        private void ADDAFTER(NODE m, NODE t) { NODE b = m.n; t.p = m; t.n = b; m.n = t; b.p = t; c++; }
    }
}
#endregion
namespace LIB
{
    public class IO
    {
        private const int WMAX = 1000;
        private StringBuilder S = new StringBuilder();
        private T R<T>(Func<string, T> f) { return f(Console.ReadLine()); }
        private T[] R<T>(Func<string, T> f, char c) { return STRING().Split(c).Select(f).ToArray(); }
        private T[] R<T>(Func<string, T> f, int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = R(f); } return r; }
        private T[][] R<T>(Func<string, T> f, int l, char c) { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = R<T>(f, c); } return r; }
        private void W<T>(Func<T, string> f, T v, bool lf = true) { S.Append(f(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { FLUSH(); } }
        public string STRING() { return R(s => s); }
        public string[] STRING(char c) { return R(s => s, c); }
        public string[] STRING(int l) { return R(s => s, l); }
        public string[][] STRING(int l, char c) { return R(s => s, l, c); }
        public int INT() { return R(int.Parse); }
        public int[] INT(char c) { return R(int.Parse, c); }
        public int[] INT(int l) { return R(int.Parse, l); }
        public int[][] INT(int l, char c) { return R(int.Parse, l, c); }
        public long LONG() { return R(long.Parse); }
        public long[] LONG(char c) { return R(long.Parse, c); }
        public long[] LONG(int l) { return R(long.Parse, l); }
        public long[][] LONG(int l, char c) { return R(long.Parse, l, c); }
        public double DOUBLE() { return R(double.Parse); }
        public double[] DOUBLE(char c) { return R(double.Parse, c); }
        public double[] DOUBLE(int l) { return R(double.Parse, l); }
        public double[][] DOUBLE(int l, char c) { return R(double.Parse, l, c); }
        public void WRITE(string s, bool lf = true) { W(v => v, s, lf); }
        public void WRITE(int s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void WRITE(long s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void WRITE(double s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void FLUSH() { Console.Write(S); S.Length = 0; }
    }
}

Measured memory_bytes: 122004