from collections import deque

n = int(input())

que = deque()

for i in range(n):
    order = input()

    if order == "deleteFirst":
        que.popleft()
    elif order == "deleteLast":
        que.pop()

    else:
        order,value = order.split()
        value = int(value)
        if order == "insert":
            que.appendleft(value)
        elif order == "delete":
            try:
                que.remove(value)
            except:
                pass

print(*que) from collections import deque n = int(input()) n int(input()) int input() input que = deque() que deque() deque for i in range(n):
    order = input()

    if order == "deleteFirst":
        que.popleft()
    elif order == "deleteLast":
        que.pop()

    else:
        order,value = order.split()
        value = int(value)
        if order == "insert":
            que.appendleft(value)
        elif order == "delete":
            try:
                que.remove(value)
            except:
                pass i range(n) range n order = input() order input() input if order == "deleteFirst":
        que.popleft()
    elif order == "deleteLast":
        que.pop()

    else:
        order,value = order.split()
        value = int(value)
        if order == "insert":
            que.appendleft(value)
        elif order == "delete":
            try:
                que.remove(value)
            except:
                pass order == "deleteFirst" order "deleteFirst" que.popleft() que.popleft que popleft elif order == "deleteLast":
        que.pop()

     order == "deleteLast" order "deleteLast" que.pop() que.pop que pop order,value = order.split() order order.split() order.split order split value value = int(value) value int(value) int value if order == "insert":
            que.appendleft(value)
        elif order == "delete":
            try:
                que.remove(value)
            except:
                pass order == "insert" order "insert" que.appendleft(value) que.appendleft que appendleft value elif order == "delete":
            try:
                que.remove(value)
            except:
                pass order == "delete" order "delete" try:
                que.remove(value)
            except:
                pass except:
                pass que.remove(value) que.remove que remove value print(*que) print *que que order = input() input() order que = deque() deque() que order,value = order.split() order.split() order value = order.split() order.split() value n = int(input()) int(input()) n value = int(value) int(value) value
from collections import deque

n = int(input())

que = deque()

for i in range(n):
    order = input()

    if order == "deleteFirst":
        que.popleft()
    elif order == "deleteLast":
        que.pop()

    else:
        order,value = order.split()
        value = int(value)
        if order == "insert":
            que.appendleft(value)
        elif order == "delete":
            try:
                que.remove(value)
            except:
                pass

print(*que)
