import sys
import collections
n = int(input())
que = collections.deque()

for _ in range(n):
    command = sys.stdin.readline()
    if 'i' == command[0]:
        command, num = command.split()
        que.appendleft(num)
    elif 'deleteFirst\n' == command:
        que.popleft()
    elif 'deleteLast\n' == command:
        que.pop()
    else:
        command, num = command.split()
        try:
            que.remove(num)
        except ValueError:
            pass
print(' '.join(map(str, que))) import sys sys import collections collections n = int(input()) n int(input()) int input() input que = collections.deque() que collections.deque() collections.deque collections deque for _ in range(n):
    command = sys.stdin.readline()
    if 'i' == command[0]:
        command, num = command.split()
        que.appendleft(num)
    elif 'deleteFirst\n' == command:
        que.popleft()
    elif 'deleteLast\n' == command:
        que.pop()
    else:
        command, num = command.split()
        try:
            que.remove(num)
        except ValueError:
            pass _ range(n) range n command = sys.stdin.readline() command sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline if 'i' == command[0]:
        command, num = command.split()
        que.appendleft(num)
    elif 'deleteFirst\n' == command:
        que.popleft()
    elif 'deleteLast\n' == command:
        que.pop()
    else:
        command, num = command.split()
        try:
            que.remove(num)
        except ValueError:
            pass 'i' == command[0] 'i' command[0] command 0 command, num = command.split() command command.split() command.split command split num que.appendleft(num) que.appendleft que appendleft num elif 'deleteFirst\n' == command:
        que.popleft()
     'deleteFirst\n' == command 'deleteFirst\n' command que.popleft() que.popleft que popleft elif 'deleteLast\n' == command:
        que.pop()
     'deleteLast\n' == command 'deleteLast\n' command que.pop() que.pop que pop command, num = command.split() command command.split() command.split command split num try:
            que.remove(num)
        except ValueError:
            pass except ValueError:
            pass que.remove(num) que.remove que remove num print(' '.join(map(str, que))) print ' '.join(map(str, que)) ' '.join ' ' join map(str, que) map str que command, num = command.split() command.split() command num = command.split() command.split() num command, num = command.split() command.split() command command = sys.stdin.readline() sys.stdin.readline() command que = collections.deque() collections.deque() que n = int(input()) int(input()) n num = command.split() command.split() num
import sys
import collections
n = int(input())
que = collections.deque()

for _ in range(n):
    command = sys.stdin.readline()
    if 'i' == command[0]:
        command, num = command.split()
        que.appendleft(num)
    elif 'deleteFirst\n' == command:
        que.popleft()
    elif 'deleteLast\n' == command:
        que.pop()
    else:
        command, num = command.split()
        try:
            que.remove(num)
        except ValueError:
            pass
print(' '.join(map(str, que)))