from collections import deque

n = int(input())

commnad = ''
key = 0
dll = deque()
cur = 0

for i in range(n):
    tmp = input()
    if ' ' in tmp:
        command, key = tmp.split(' ')
    else:
        command = tmp

    if command == 'insert':
        dll.appendleft(key)
    elif command == 'delete':
        try:
            dll.remove(key)
        except:
            pass
    elif command == 'deleteFirst':
        dll.popleft()
    elif command == 'deleteLast':
        dll.pop()

res = ''
for i in dll:
    res += i
    res += ' '
print(res[:-1]) from collections import deque n = int(input()) n int(input()) int input() input commnad = '' commnad '' key = 0 key 0 dll = deque() dll deque() deque cur = 0 cur 0 for i in range(n):
    tmp = input()
    if ' ' in tmp:
        command, key = tmp.split(' ')
    else:
        command = tmp

    if command == 'insert':
        dll.appendleft(key)
    elif command == 'delete':
        try:
            dll.remove(key)
        except:
            pass
    elif command == 'deleteFirst':
        dll.popleft()
    elif command == 'deleteLast':
        dll.pop() i range(n) range n tmp = input() tmp input() input if ' ' in tmp:
        command, key = tmp.split(' ')
    else:
        command = tmp

     ' ' in tmp ' ' tmp command, key = tmp.split(' ') command tmp.split(' ') tmp.split tmp split ' ' key command = tmp command tmp if command == 'insert':
        dll.appendleft(key)
    elif command == 'delete':
        try:
            dll.remove(key)
        except:
            pass
    elif command == 'deleteFirst':
        dll.popleft()
    elif command == 'deleteLast':
        dll.pop() command == 'insert' command 'insert' dll.appendleft(key) dll.appendleft dll appendleft key elif command == 'delete':
        try:
            dll.remove(key)
        except:
            pass
     command == 'delete' command 'delete' try:
            dll.remove(key)
        except:
            pass
     except:
            pass
     dll.remove(key) dll.remove dll remove key elif command == 'deleteFirst':
        dll.popleft()
     command == 'deleteFirst' command 'deleteFirst' dll.popleft() dll.popleft dll popleft elif command == 'deleteLast':
        dll.pop() command == 'deleteLast' command 'deleteLast' dll.pop() dll.pop dll pop res = '' res '' for i in dll:
    res += i
    res += ' ' i dll res += i res i res += ' ' res ' ' print(res[:-1]) print res[:-1] res :-1 -1 n = int(input()) int(input()) n command, key = tmp.split(' ') tmp.split(' ') command commnad = '' '' commnad cur = 0 0 cur dll = deque() deque() dll command = tmp tmp command res += i i res res += ' ' ' ' res tmp = input() input() tmp key = tmp.split(' ') tmp.split(' ') key res = '' '' res key = 0 0 key
from collections import deque

n = int(input())

commnad = ''
key = 0
dll = deque()
cur = 0

for i in range(n):
    tmp = input()
    if ' ' in tmp:
        command, key = tmp.split(' ')
    else:
        command = tmp

    if command == 'insert':
        dll.appendleft(key)
    elif command == 'delete':
        try:
            dll.remove(key)
        except:
            pass
    elif command == 'deleteFirst':
        dll.popleft()
    elif command == 'deleteLast':
        dll.pop()

res = ''
for i in dll:
    res += i
    res += ' '
print(res[:-1])
