# -*- coding:utf-8 -*-
import collections
n = int(input())
command = [input().split() for i in range(n)]
ans = collections.deque()

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

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

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

print (' '.join(ans))