# -*- coding:utf-8 -*-
import collections
n = int(input())
ans = collections.deque()

for i in range(n):
    command = input().split()
    if command[0] == "insert":
        ans.appendleft(command[1])
    elif ans == []:
        continue
    elif command[0] == "delete":
        try:
            ans.remove(command[1])
        except:
            pass
    elif command[0] == "deleteFirst":
        ans.popleft()
    else:
        ans.pop()

print (' '.join(ans)) import collections collections n = int(input()) n int(input()) int input() input ans = collections.deque() ans collections.deque() collections.deque collections deque for i in range(n):
    command = input().split()
    if command[0] == "insert":
        ans.appendleft(command[1])
    elif ans == []:
        continue
    elif command[0] == "delete":
        try:
            ans.remove(command[1])
        except:
            pass
    elif command[0] == "deleteFirst":
        ans.popleft()
    else:
        ans.pop() i range(n) range n command = input().split() command input().split() ().split () input split if command[0] == "insert":
        ans.appendleft(command[1])
    elif ans == []:
        continue
    elif command[0] == "delete":
        try:
            ans.remove(command[1])
        except:
            pass
    elif command[0] == "deleteFirst":
        ans.popleft()
    else:
        ans.pop() command[0] == "insert" command[0] command 0 "insert" ans.appendleft(command[1]) ans.appendleft ans appendleft command[1] command 1 elif ans == []:
        continue
     ans == [] ans [] continue elif command[0] == "delete":
        try:
            ans.remove(command[1])
        except:
            pass
     command[0] == "delete" command[0] command 0 "delete" try:
            ans.remove(command[1])
        except:
            pass
     except:
            pass
     ans.remove(command[1]) ans.remove ans remove command[1] command 1 elif command[0] == "deleteFirst":
        ans.popleft()
     command[0] == "deleteFirst" command[0] command 0 "deleteFirst" ans.popleft() ans.popleft ans popleft ans.pop() ans.pop ans pop print (' '.join(ans)) print ' '.join(ans) ' '.join ' ' join ans n = int(input()) int(input()) n ans = collections.deque() collections.deque() ans command = input().split() input().split() command
# -*- coding:utf-8 -*-
import collections
n = int(input())
ans = collections.deque()

for i in range(n):
    command = input().split()
    if command[0] == "insert":
        ans.appendleft(command[1])
    elif ans == []:
        continue
    elif command[0] == "delete":
        try:
            ans.remove(command[1])
        except:
            pass
    elif command[0] == "deleteFirst":
        ans.popleft()
    else:
        ans.pop()

print (' '.join(ans))