from collections import deque
n = int(input())
L = deque()
for i in range(n):
    command = input()
    if command == 'deleteFirst':
        L.popleft()
    elif command == 'deleteLast':
        L.pop()
    else:
        c, x = command.split()
        if c == 'insert':
            L.appendleft(x)
        elif c == 'delete':
            try:
                L.remove(x)
            except ValueError:
                pass
print(' '.join(L)) from collections import deque n = int(input()) n int(input()) int input() input L = deque() L deque() deque for i in range(n):
    command = input()
    if command == 'deleteFirst':
        L.popleft()
    elif command == 'deleteLast':
        L.pop()
    else:
        c, x = command.split()
        if c == 'insert':
            L.appendleft(x)
        elif c == 'delete':
            try:
                L.remove(x)
            except ValueError:
                pass i range(n) range n command = input() command input() input if command == 'deleteFirst':
        L.popleft()
    elif command == 'deleteLast':
        L.pop()
    else:
        c, x = command.split()
        if c == 'insert':
            L.appendleft(x)
        elif c == 'delete':
            try:
                L.remove(x)
            except ValueError:
                pass command == 'deleteFirst' command 'deleteFirst' L.popleft() L.popleft L popleft elif command == 'deleteLast':
        L.pop()
     command == 'deleteLast' command 'deleteLast' L.pop() L.pop L pop c, x = command.split() c command.split() command.split command split x if c == 'insert':
            L.appendleft(x)
        elif c == 'delete':
            try:
                L.remove(x)
            except ValueError:
                pass c == 'insert' c 'insert' L.appendleft(x) L.appendleft L appendleft x elif c == 'delete':
            try:
                L.remove(x)
            except ValueError:
                pass c == 'delete' c 'delete' try:
                L.remove(x)
            except ValueError:
                pass except ValueError:
                pass L.remove(x) L.remove L remove x print(' '.join(L)) print ' '.join(L) ' '.join ' ' join L x = command.split() command.split() x command = input() input() command c, x = command.split() command.split() c n = int(input()) int(input()) n L = deque() deque() L
from collections import deque
n = int(input())
L = deque()
for i in range(n):
    command = input()
    if command == 'deleteFirst':
        L.popleft()
    elif command == 'deleteLast':
        L.pop()
    else:
        c, x = command.split()
        if c == 'insert':
            L.appendleft(x)
        elif c == 'delete':
            try:
                L.remove(x)
            except ValueError:
                pass
print(' '.join(L))
