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

namespace _20180305_AOJ
{
    class ALDS1_3C
    {
        static void Main(string[] args)
        {
            for (;;)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line))
                {
                    break;
                }
                
                List2 list = new List2();
                int n = int.Parse(line);
                for (int i = 0; i < n; i++)
                {
                    string[] command = Console.ReadLine().Split(' ');
                    if (command.Length > 1)
                    {
                        string val = command[1];
                        switch (command[0])
                        {
                            case "insert":
                                list.Insert(int.Parse(val));
                                break;
                            case "delete":
                                list.Delete(int.Parse(val));
                                break;
                        }
                    }
                    else
                    {
                        switch (command[0])
                        {
                            case "deleteFirst":
                                list.DeleteFirst();
                                break;
                            case "deleteLast":
                                list.DeleteLast();
                                break;
                        }
                    }
                }

                int[] buffer = list.GetBuffer();
                for (int i = 0; i < buffer.Length - 1; i++)
                {
                    Console.Write(string.Format("{0} ", buffer[i]));
                }
                Console.WriteLine(buffer[buffer.Length - 1]);
            }
        }

        class List2
        {
            int[] buffer;
            int first;
            int last;

            public List2()
            {
                buffer = new int[1000020];
                first = buffer.Length;
                last = buffer.Length - 1;
            }

            public void Insert(int val)
            {
                first--;
                buffer[first] = val;
            }

            public void Delete(int val)
            {
                for(int i=first; i<=last; i++)
                {
                    if (buffer[i] == val)
                    {
                        if(i==first)
                        {
                            first++;
                        }
                        else if (i == last)
                        {
                            last--;
                        }
                        else
                        {
                            buffer[i] = -1;
                        }
                        break;
                    }
                }
            }

            public void DeleteFirst()
            {
                first++;
            }

            public void DeleteLast()
            {
                last--;
            }

            public int[] GetBuffer()
            {
                List<int> list = new List<int>();
                for(int i = first;i<=last;i++)
                {
                    if(buffer[i]>=0)
                    {
                        list.Add(buffer[i]);
                    }
                }

                return list.ToArray();
            }
        }
    }
}



Measured memory_bytes: 16648