from collections import deque
que = deque()

n = int(input())
for _ in range(n):
    command = input()
    if command == 'deleteFirst':
        que.popleft()
    elif command == 'deleteLast':
        que.pop()
    else:
        x, y = command.split()
        if x == 'insert':
            que.appendleft(int(y))
        elif int(y) in que:
            que.remove(int(y))

print(' '.join(map(str, que))) from collections import deque que = deque() que deque() deque n = int(input()) n int(input()) int input() input for _ in range(n):
    command = input()
    if command == 'deleteFirst':
        que.popleft()
    elif command == 'deleteLast':
        que.pop()
    else:
        x, y = command.split()
        if x == 'insert':
            que.appendleft(int(y))
        elif int(y) in que:
            que.remove(int(y)) _ range(n) range n command = input() command input() input if command == 'deleteFirst':
        que.popleft()
    elif command == 'deleteLast':
        que.pop()
    else:
        x, y = command.split()
        if x == 'insert':
            que.appendleft(int(y))
        elif int(y) in que:
            que.remove(int(y)) command == 'deleteFirst' command 'deleteFirst' que.popleft() que.popleft que popleft elif command == 'deleteLast':
        que.pop()
     command == 'deleteLast' command 'deleteLast' que.pop() que.pop que pop x, y = command.split() x command.split() command.split command split y if x == 'insert':
            que.appendleft(int(y))
        elif int(y) in que:
            que.remove(int(y)) x == 'insert' x 'insert' que.appendleft(int(y)) que.appendleft que appendleft int(y) int y elif int(y) in que:
            que.remove(int(y)) int(y) in que int(y) int y que que.remove(int(y)) que.remove que remove int(y) int y print(' '.join(map(str, que))) print ' '.join(map(str, que)) ' '.join ' ' join map(str, que) map str que command = input() input() command y = command.split() command.split() y x, y = command.split() command.split() x que = deque() deque() que n = int(input()) int(input()) n
from collections import deque
que = deque()

n = int(input())
for _ in range(n):
    command = input()
    if command == 'deleteFirst':
        que.popleft()
    elif command == 'deleteLast':
        que.pop()
    else:
        x, y = command.split()
        if x == 'insert':
            que.appendleft(int(y))
        elif int(y) in que:
            que.remove(int(y))

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