from collections import deque

N = int(input())
L = deque()

for i in range(N):
    C= input().split()

    if C[0] == "insert":
        L.appendleft(C[1])

    elif C[0] == "delete":
        try:
            L.remove(C[1])
        except ValueError:
                pass
    elif C[0] == "deleteFirst":
        L.popleft()
    elif C[0] == "deleteLast":
        L.pop()
    
print(" ".join(L))
 from collections import deque N = int(input()) N int(input()) int input() input L = deque() L deque() deque for i in range(N):
    C= input().split()

    if C[0] == "insert":
        L.appendleft(C[1])

    elif C[0] == "delete":
        try:
            L.remove(C[1])
        except ValueError:
                pass
    elif C[0] == "deleteFirst":
        L.popleft()
    elif C[0] == "deleteLast":
        L.pop()
     i range(N) range N C= input().split() C input().split() ().split () input split if C[0] == "insert":
        L.appendleft(C[1])

    elif C[0] == "delete":
        try:
            L.remove(C[1])
        except ValueError:
                pass
    elif C[0] == "deleteFirst":
        L.popleft()
    elif C[0] == "deleteLast":
        L.pop()
     C[0] == "insert" C[0] C 0 "insert" L.appendleft(C[1]) L.appendleft L appendleft C[1] C 1 elif C[0] == "delete":
        try:
            L.remove(C[1])
        except ValueError:
                pass
     C[0] == "delete" C[0] C 0 "delete" try:
            L.remove(C[1])
        except ValueError:
                pass
     except ValueError:
                pass
     L.remove(C[1]) L.remove L remove C[1] C 1 elif C[0] == "deleteFirst":
        L.popleft()
     C[0] == "deleteFirst" C[0] C 0 "deleteFirst" L.popleft() L.popleft L popleft elif C[0] == "deleteLast":
        L.pop()
     C[0] == "deleteLast" C[0] C 0 "deleteLast" L.pop() L.pop L pop print(" ".join(L)) print " ".join(L) " ".join " " join L L = deque() deque() L N = int(input()) int(input()) N C= input().split() input().split() C
from collections import deque

N = int(input())
L = deque()

for i in range(N):
    C= input().split()

    if C[0] == "insert":
        L.appendleft(C[1])

    elif C[0] == "delete":
        try:
            L.remove(C[1])
        except ValueError:
                pass
    elif C[0] == "deleteFirst":
        L.popleft()
    elif C[0] == "deleteLast":
        L.pop()
    
print(" ".join(L))

