from collections import deque
n = int(input())
d = deque()

for i in range(n):
    line = input().split()
    if len(line) == 2:
        command, ele = line
    else:
        command = line[0]

    if command == 'insert':
        d.appendleft(ele)
    elif command == 'delete':
        if ele in d:
            d.remove(ele)
    elif command == 'deleteFirst':
        d.popleft()
    elif command == 'deleteLast':
        d.pop()

print(' '.join(list(d))) from collections import deque n = int(input()) n int(input()) int input() input d = deque() d deque() deque for i in range(n):
    line = input().split()
    if len(line) == 2:
        command, ele = line
    else:
        command = line[0]

    if command == 'insert':
        d.appendleft(ele)
    elif command == 'delete':
        if ele in d:
            d.remove(ele)
    elif command == 'deleteFirst':
        d.popleft()
    elif command == 'deleteLast':
        d.pop() i range(n) range n line = input().split() line input().split() ().split () input split if len(line) == 2:
        command, ele = line
    else:
        command = line[0]

     len(line) == 2 len(line) len line 2 command, ele = line command line ele command = line[0] command line[0] line 0 if command == 'insert':
        d.appendleft(ele)
    elif command == 'delete':
        if ele in d:
            d.remove(ele)
    elif command == 'deleteFirst':
        d.popleft()
    elif command == 'deleteLast':
        d.pop() command == 'insert' command 'insert' d.appendleft(ele) d.appendleft d appendleft ele elif command == 'delete':
        if ele in d:
            d.remove(ele)
     command == 'delete' command 'delete' if ele in d:
            d.remove(ele)
     ele in d ele d d.remove(ele) d.remove d remove ele elif command == 'deleteFirst':
        d.popleft()
     command == 'deleteFirst' command 'deleteFirst' d.popleft() d.popleft d popleft elif command == 'deleteLast':
        d.pop() command == 'deleteLast' command 'deleteLast' d.pop() d.pop d pop print(' '.join(list(d))) print ' '.join(list(d)) ' '.join ' ' join list(d) list d d = deque() deque() d ele = line line ele line = input().split() input().split() line n = int(input()) int(input()) n command = line[0] line[0] command command, ele = line line command
from collections import deque
n = int(input())
d = deque()

for i in range(n):
    line = input().split()
    if len(line) == 2:
        command, ele = line
    else:
        command = line[0]

    if command == 'insert':
        d.appendleft(ele)
    elif command == 'delete':
        if ele in d:
            d.remove(ele)
    elif command == 'deleteFirst':
        d.popleft()
    elif command == 'deleteLast':
        d.pop()

print(' '.join(list(d)))