import sys
from collections import deque

n = int( sys.stdin.readline( ) )
que = deque( )
lines = sys.stdin.readlines()
for line in lines:
	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( )
	elif "deleteLast" == op[0]:
		que.pop( )


print( " ".join( que ) )
51d1019ab5c60e8f7a5aa30c570db1ca2e77ed6b
<mask token>

<mask token>
for line in lines:
    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()
    elif 'deleteLast' == op[0]:
        que.pop()
print(' '.join(que))

<mask token>
n = int(sys.stdin.readline())
que = deque()
lines = sys.stdin.readlines()
for line in lines:
    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()
    elif 'deleteLast' == op[0]:
        que.pop()
print(' '.join(que))

import sys
from collections import deque
n = int(sys.stdin.readline())
que = deque()
lines = sys.stdin.readlines()
for line in lines:
    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()
    elif 'deleteLast' == op[0]:
        que.pop()
print(' '.join(que))

import sys
from collections import deque

n = int( sys.stdin.readline( ) )
que = deque( )
lines = sys.stdin.readlines()
for line in lines:
	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( )
	elif "deleteLast" == op[0]:
		que.pop( )


print( " ".join( que ) )