#coding:utf-8
#1_3_C
from collections import deque
n = int(input())
ary = deque()
for i in range(n):
    cmd = input().split()
    if cmd[0] == "insert":
        ary.appendleft(cmd[1])
    elif cmd[0] == "delete":
        try:
            ary.remove(cmd[1])
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        ary.popleft()
    elif cmd[0] == "deleteLast":
        ary.pop()

print(" ".join(ary)) from collections import deque n = int(input()) n int(input()) int input() input ary = deque() ary deque() deque for i in range(n):
    cmd = input().split()
    if cmd[0] == "insert":
        ary.appendleft(cmd[1])
    elif cmd[0] == "delete":
        try:
            ary.remove(cmd[1])
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        ary.popleft()
    elif cmd[0] == "deleteLast":
        ary.pop() i range(n) range n cmd = input().split() cmd input().split() ().split () input split if cmd[0] == "insert":
        ary.appendleft(cmd[1])
    elif cmd[0] == "delete":
        try:
            ary.remove(cmd[1])
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        ary.popleft()
    elif cmd[0] == "deleteLast":
        ary.pop() cmd[0] == "insert" cmd[0] cmd 0 "insert" ary.appendleft(cmd[1]) ary.appendleft ary appendleft cmd[1] cmd 1 elif cmd[0] == "delete":
        try:
            ary.remove(cmd[1])
        except ValueError:
            pass
     cmd[0] == "delete" cmd[0] cmd 0 "delete" try:
            ary.remove(cmd[1])
        except ValueError:
            pass
     except ValueError:
            pass
     ary.remove(cmd[1]) ary.remove ary remove cmd[1] cmd 1 elif cmd[0] == "deleteFirst":
        ary.popleft()
     cmd[0] == "deleteFirst" cmd[0] cmd 0 "deleteFirst" ary.popleft() ary.popleft ary popleft elif cmd[0] == "deleteLast":
        ary.pop() cmd[0] == "deleteLast" cmd[0] cmd 0 "deleteLast" ary.pop() ary.pop ary pop print(" ".join(ary)) print " ".join(ary) " ".join " " join ary n = int(input()) int(input()) n cmd = input().split() input().split() cmd ary = deque() deque() ary
#coding:utf-8
#1_3_C
from collections import deque
n = int(input())
ary = deque()
for i in range(n):
    cmd = input().split()
    if cmd[0] == "insert":
        ary.appendleft(cmd[1])
    elif cmd[0] == "delete":
        try:
            ary.remove(cmd[1])
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        ary.popleft()
    elif cmd[0] == "deleteLast":
        ary.pop()

print(" ".join(ary))