import sys
from collections import deque

d = deque()
n = int(input())
lines = sys.stdin.readlines()
for i in range(n):
    ins = lines[i].split()
    command = ins[0]
    if command == "insert":
        d.appendleft(ins[1])
    elif command == "delete":
        try:
            d.remove(ins[1])
        except:
            pass
    elif command == "deleteFirst":
        d.popleft()
    elif command == "deleteLast":
        d.pop()

print(" ".join(d)) import sys sys from collections import deque d = deque() d deque() deque n = int(input()) n int(input()) int input() input lines = sys.stdin.readlines() lines sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines for i in range(n):
    ins = lines[i].split()
    command = ins[0]
    if command == "insert":
        d.appendleft(ins[1])
    elif command == "delete":
        try:
            d.remove(ins[1])
        except:
            pass
    elif command == "deleteFirst":
        d.popleft()
    elif command == "deleteLast":
        d.pop() i range(n) range n ins = lines[i].split() ins lines[i].split() [i].split [i] lines i split command = ins[0] command ins[0] ins 0 if command == "insert":
        d.appendleft(ins[1])
    elif command == "delete":
        try:
            d.remove(ins[1])
        except:
            pass
    elif command == "deleteFirst":
        d.popleft()
    elif command == "deleteLast":
        d.pop() command == "insert" command "insert" d.appendleft(ins[1]) d.appendleft d appendleft ins[1] ins 1 elif command == "delete":
        try:
            d.remove(ins[1])
        except:
            pass
     command == "delete" command "delete" try:
            d.remove(ins[1])
        except:
            pass
     except:
            pass
     d.remove(ins[1]) d.remove d remove ins[1] ins 1 elif command == "deleteFirst":
        d.popleft()
     command == "deleteFirst" command "deleteFirst" d.popleft() d.popleft d popleft elif command == "deleteLast":
        d.pop() command == "deleteLast" command "deleteLast" d.pop() d.pop d pop print(" ".join(d)) print " ".join(d) " ".join " " join d d = deque() deque() d n = int(input()) int(input()) n lines = sys.stdin.readlines() sys.stdin.readlines() lines ins = lines[i].split() lines[i].split() ins command = ins[0] ins[0] command
import sys
from collections import deque

d = deque()
n = int(input())
lines = sys.stdin.readlines()
for i in range(n):
    ins = lines[i].split()
    command = ins[0]
    if command == "insert":
        d.appendleft(ins[1])
    elif command == "delete":
        try:
            d.remove(ins[1])
        except:
            pass
    elif command == "deleteFirst":
        d.popleft()
    elif command == "deleteLast":
        d.pop()

print(" ".join(d))