from collections import deque
  
n = int(input())
dll = deque()
  
for i in range(n):
    input_line = input().split()
    if input_line[0] == "insert":
        dll.appendleft(input_line[1])
    elif len(dll) == 0:
        continue
    elif input_line[0] == "delete":
        try:
            dll.remove(input_line[1])
        except:
            pass
    elif input_line[0] == "deleteFirst":
        dll.popleft()
    else:
        dll.pop()
          
print(*dll) from collections import deque n = int(input()) n int(input()) int input() input dll = deque() dll deque() deque for i in range(n):
    input_line = input().split()
    if input_line[0] == "insert":
        dll.appendleft(input_line[1])
    elif len(dll) == 0:
        continue
    elif input_line[0] == "delete":
        try:
            dll.remove(input_line[1])
        except:
            pass
    elif input_line[0] == "deleteFirst":
        dll.popleft()
    else:
        dll.pop()
           i range(n) range n input_line = input().split() input_line input().split() ().split () input split if input_line[0] == "insert":
        dll.appendleft(input_line[1])
    elif len(dll) == 0:
        continue
    elif input_line[0] == "delete":
        try:
            dll.remove(input_line[1])
        except:
            pass
    elif input_line[0] == "deleteFirst":
        dll.popleft()
    else:
        dll.pop()
           input_line[0] == "insert" input_line[0] input_line 0 "insert" dll.appendleft(input_line[1]) dll.appendleft dll appendleft input_line[1] input_line 1 elif len(dll) == 0:
        continue
     len(dll) == 0 len(dll) len dll 0 continue elif input_line[0] == "delete":
        try:
            dll.remove(input_line[1])
        except:
            pass
     input_line[0] == "delete" input_line[0] input_line 0 "delete" try:
            dll.remove(input_line[1])
        except:
            pass
     except:
            pass
     dll.remove(input_line[1]) dll.remove dll remove input_line[1] input_line 1 elif input_line[0] == "deleteFirst":
        dll.popleft()
     input_line[0] == "deleteFirst" input_line[0] input_line 0 "deleteFirst" dll.popleft() dll.popleft dll popleft dll.pop() dll.pop dll pop print(*dll) print *dll dll input_line = input().split() input().split() input_line n = int(input()) int(input()) n dll = deque() deque() dll
from collections import deque
  
n = int(input())
dll = deque()
  
for i in range(n):
    input_line = input().split()
    if input_line[0] == "insert":
        dll.appendleft(input_line[1])
    elif len(dll) == 0:
        continue
    elif input_line[0] == "delete":
        try:
            dll.remove(input_line[1])
        except:
            pass
    elif input_line[0] == "deleteFirst":
        dll.popleft()
    else:
        dll.pop()
          
print(*dll)