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

class Program
{
    public void Proc()
    {
        int commandCount = int.Parse(Console.ReadLine());

        long[] linear = new long[(int)Math.Min(commandCount, Math.Pow(10, 6))+1];
        int itemCount = 0;

        for(int i=0; i<commandCount; i++)
        {
            string[] inpt = Console.ReadLine().Split(' ');
            long num = 0;

            if (inpt.Length >= 2)
            {
                num = long.Parse(inpt[1]);
            }

            switch (inpt[0])
            {
                case "insert":
                    for(int j= itemCount-1; j>=0; j--)
                    {
                        linear[j + 1] = linear[j];
                    }
                    linear[0] = num;
                    itemCount++;
                    break;
                case "delete":
                    bool isFinded = false;
                    for(int j=0; j<itemCount; j++)
                    {
                        if(linear[j] == num)
                        {
                            isFinded = true;
                        }
                        if(isFinded)
                        {
                            linear[j] = linear[j + 1];
                        }
                    }
                    itemCount--;
                    break;
                case "deleteFirst":
                    for(int j=0; j<itemCount;j++)
                    {
                        linear[j] = linear[j + 1];
                    }
                    itemCount--;
                    break;
                case "deleteLast":
                    linear[itemCount - 1] = -1;
                    itemCount--;
                    break; 
            }
        }
        StringBuilder ans = new StringBuilder();
        for(int i=0; i<itemCount; i++)
        {
            if(ans.Length > 0)
            {
                ans.Append(" ");
            }
            ans.Append(linear[i]);
        }
        Console.WriteLine(ans.ToString());
        
    }

    static void Main(string[] args)

    {

        Program prg = new Program();
        prg.Proc();

    }
}