import collections


Q = collections.deque()
n = int(input())

for _ in range(n):
    input_value = input().split()
    if input_value[0] == 'insert':
        Q.appendleft(input_value[1])
    elif input_value[0] == 'delete':
        if input_value[1] in Q:
            Q.remove(input_value[1])
    elif input_value[0] == 'deleteFirst':
        Q.popleft()
    elif input_value[0] == 'deleteLast':
        Q.pop()
    else:
        raise Error("illegal state")

print(' '.join(map(str, Q)))
 import collections collections Q = collections.deque() Q collections.deque() collections.deque collections deque n = int(input()) n int(input()) int input() input for _ in range(n):
    input_value = input().split()
    if input_value[0] == 'insert':
        Q.appendleft(input_value[1])
    elif input_value[0] == 'delete':
        if input_value[1] in Q:
            Q.remove(input_value[1])
    elif input_value[0] == 'deleteFirst':
        Q.popleft()
    elif input_value[0] == 'deleteLast':
        Q.pop()
    else:
        raise Error("illegal state") _ range(n) range n input_value = input().split() input_value input().split() ().split () input split if input_value[0] == 'insert':
        Q.appendleft(input_value[1])
    elif input_value[0] == 'delete':
        if input_value[1] in Q:
            Q.remove(input_value[1])
    elif input_value[0] == 'deleteFirst':
        Q.popleft()
    elif input_value[0] == 'deleteLast':
        Q.pop()
    else:
        raise Error("illegal state") input_value[0] == 'insert' input_value[0] input_value 0 'insert' Q.appendleft(input_value[1]) Q.appendleft Q appendleft input_value[1] input_value 1 elif input_value[0] == 'delete':
        if input_value[1] in Q:
            Q.remove(input_value[1])
     input_value[0] == 'delete' input_value[0] input_value 0 'delete' if input_value[1] in Q:
            Q.remove(input_value[1])
     input_value[1] in Q input_value[1] input_value 1 Q Q.remove(input_value[1]) Q.remove Q remove input_value[1] input_value 1 elif input_value[0] == 'deleteFirst':
        Q.popleft()
     input_value[0] == 'deleteFirst' input_value[0] input_value 0 'deleteFirst' Q.popleft() Q.popleft Q popleft elif input_value[0] == 'deleteLast':
        Q.pop()
     input_value[0] == 'deleteLast' input_value[0] input_value 0 'deleteLast' Q.pop() Q.pop Q pop raise Error("illegal state") Error("illegal state") Error "illegal state" print(' '.join(map(str, Q))) print ' '.join(map(str, Q)) ' '.join ' ' join map(str, Q) map str Q n = int(input()) int(input()) n input_value = input().split() input().split() input_value Q = collections.deque() collections.deque() Q
import collections


Q = collections.deque()
n = int(input())

for _ in range(n):
    input_value = input().split()
    if input_value[0] == 'insert':
        Q.appendleft(input_value[1])
    elif input_value[0] == 'delete':
        if input_value[1] in Q:
            Q.remove(input_value[1])
    elif input_value[0] == 'deleteFirst':
        Q.popleft()
    elif input_value[0] == 'deleteLast':
        Q.pop()
    else:
        raise Error("illegal state")

print(' '.join(map(str, Q)))

