from collections import deque

n = int(input())
Q= deque()

for _ in range(n):
    str = input()
    if str == "deleteFirst":
        Q.popleft()
    elif str == "deleteLast":
        Q.pop()
    else:
        cmd,key = str.split()
        if cmd == "insert":
            Q.appendleft(key)
        elif cmd == "delete":
            try:
                Q.remove(key)
            except:
                pass
print(" ".join(list(Q))) from collections import deque n = int(input()) n int(input()) int input() input Q= deque() Q deque() deque for _ in range(n):
    str = input()
    if str == "deleteFirst":
        Q.popleft()
    elif str == "deleteLast":
        Q.pop()
    else:
        cmd,key = str.split()
        if cmd == "insert":
            Q.appendleft(key)
        elif cmd == "delete":
            try:
                Q.remove(key)
            except:
                pass _ range(n) range n str = input() str input() input if str == "deleteFirst":
        Q.popleft()
    elif str == "deleteLast":
        Q.pop()
    else:
        cmd,key = str.split()
        if cmd == "insert":
            Q.appendleft(key)
        elif cmd == "delete":
            try:
                Q.remove(key)
            except:
                pass str == "deleteFirst" str "deleteFirst" Q.popleft() Q.popleft Q popleft elif str == "deleteLast":
        Q.pop()
     str == "deleteLast" str "deleteLast" Q.pop() Q.pop Q pop cmd,key = str.split() cmd str.split() str.split str split key if cmd == "insert":
            Q.appendleft(key)
        elif cmd == "delete":
            try:
                Q.remove(key)
            except:
                pass cmd == "insert" cmd "insert" Q.appendleft(key) Q.appendleft Q appendleft key elif cmd == "delete":
            try:
                Q.remove(key)
            except:
                pass cmd == "delete" cmd "delete" try:
                Q.remove(key)
            except:
                pass except:
                pass Q.remove(key) Q.remove Q remove key print(" ".join(list(Q))) print " ".join(list(Q)) " ".join " " join list(Q) list Q n = int(input()) int(input()) n key = str.split() str.split() key cmd,key = str.split() str.split() cmd str = input() input() str Q= deque() deque() Q
from collections import deque

n = int(input())
Q= deque()

for _ in range(n):
    str = input()
    if str == "deleteFirst":
        Q.popleft()
    elif str == "deleteLast":
        Q.pop()
    else:
        cmd,key = str.split()
        if cmd == "insert":
            Q.appendleft(key)
        elif cmd == "delete":
            try:
                Q.remove(key)
            except:
                pass
print(" ".join(list(Q)))
