from collections import deque

DLL = deque()

n = int(input())
for _ in range(n):
    command = input()
    if command == 'deleteFirst':
        DLL.popleft()
    elif command == 'deleteLast':
        DLL.pop()
    else:
        command, x = command.split()
        if command == 'insert':
            DLL.appendleft(x)
        elif command == 'delete':
            try:
                DLL.remove(x)
            except ValueError:
                pass
            
print(' '.join(DLL)) from collections import deque DLL = deque() DLL deque() deque n = int(input()) n int(input()) int input() input for _ in range(n):
    command = input()
    if command == 'deleteFirst':
        DLL.popleft()
    elif command == 'deleteLast':
        DLL.pop()
    else:
        command, x = command.split()
        if command == 'insert':
            DLL.appendleft(x)
        elif command == 'delete':
            try:
                DLL.remove(x)
            except ValueError:
                pass
             _ range(n) range n command = input() command input() input if command == 'deleteFirst':
        DLL.popleft()
    elif command == 'deleteLast':
        DLL.pop()
    else:
        command, x = command.split()
        if command == 'insert':
            DLL.appendleft(x)
        elif command == 'delete':
            try:
                DLL.remove(x)
            except ValueError:
                pass
             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 command, x = command.split() command command.split() command.split command split x if command == 'insert':
            DLL.appendleft(x)
        elif command == 'delete':
            try:
                DLL.remove(x)
            except ValueError:
                pass
             command == 'insert' command 'insert' DLL.appendleft(x) DLL.appendleft DLL appendleft x elif command == 'delete':
            try:
                DLL.remove(x)
            except ValueError:
                pass
             command == 'delete' command 'delete' try:
                DLL.remove(x)
            except ValueError:
                pass
             except ValueError:
                pass
             DLL.remove(x) DLL.remove DLL remove x print(' '.join(DLL)) print ' '.join(DLL) ' '.join ' ' join DLL n = int(input()) int(input()) n command, x = command.split() command.split() command DLL = deque() deque() DLL command = input() input() command x = command.split() command.split() x
from collections import deque

DLL = deque()

n = int(input())
for _ in range(n):
    command = input()
    if command == 'deleteFirst':
        DLL.popleft()
    elif command == 'deleteLast':
        DLL.pop()
    else:
        command, x = command.split()
        if command == 'insert':
            DLL.appendleft(x)
        elif command == 'delete':
            try:
                DLL.remove(x)
            except ValueError:
                pass
            
print(' '.join(DLL))
