import sys
from collections import deque
 
n = int(sys.stdin.readline())
que = deque()
for i in range(n):
    line = sys.stdin.readline()
    op = line.rstrip().split()
    if "insert" == op[0]:
        que.appendleft(op[1])
    elif "delete" == op[0]:
        if op[1] in que:
            que.remove(op[1])
    elif "deleteFirst" == op[0]:
        que.popleft()
    else:
        que.pop()
 
print(*que) import sys sys from collections import deque n = int(sys.stdin.readline()) n int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline que = deque() que deque() deque for i in range(n):
    line = sys.stdin.readline()
    op = line.rstrip().split()
    if "insert" == op[0]:
        que.appendleft(op[1])
    elif "delete" == op[0]:
        if op[1] in que:
            que.remove(op[1])
    elif "deleteFirst" == op[0]:
        que.popleft()
    else:
        que.pop()
  i range(n) range n line = sys.stdin.readline() line sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline op = line.rstrip().split() op line.rstrip().split() line.rstrip().split line.rstrip() line.rstrip line rstrip split if "insert" == op[0]:
        que.appendleft(op[1])
    elif "delete" == op[0]:
        if op[1] in que:
            que.remove(op[1])
    elif "deleteFirst" == op[0]:
        que.popleft()
    else:
        que.pop()
  "insert" == op[0] "insert" op[0] op 0 que.appendleft(op[1]) que.appendleft que appendleft op[1] op 1 elif "delete" == op[0]:
        if op[1] in que:
            que.remove(op[1])
     "delete" == op[0] "delete" op[0] op 0 if op[1] in que:
            que.remove(op[1])
     op[1] in que op[1] op 1 que que.remove(op[1]) que.remove que remove op[1] op 1 elif "deleteFirst" == op[0]:
        que.popleft()
     "deleteFirst" == op[0] "deleteFirst" op[0] op 0 que.popleft() que.popleft que popleft que.pop() que.pop que pop print(*que) print *que que n = int(sys.stdin.readline()) int(sys.stdin.readline()) n op = line.rstrip().split() line.rstrip().split() op line = sys.stdin.readline() sys.stdin.readline() line que = deque() deque() que
import sys
from collections import deque
 
n = int(sys.stdin.readline())
que = deque()
for i in range(n):
    line = sys.stdin.readline()
    op = line.rstrip().split()
    if "insert" == op[0]:
        que.appendleft(op[1])
    elif "delete" == op[0]:
        if op[1] in que:
            que.remove(op[1])
    elif "deleteFirst" == op[0]:
        que.popleft()
    else:
        que.pop()
 
print(*que)