from sys import stdin
from collections import deque

# 入力
n = int(input())

# command = [stdin.readline()[:-1] for a in range(n)]
command = stdin

# process
output = deque([])

for a in command:
    if a[0] == 'i':
        output.appendleft(int(a[7:]))
    elif a[0:7] == 'delete ':
        try:
            output.remove(int(a[7:]))
        except ValueError:
            pass
    elif a[6] == 'F':
        output.popleft()
    else:
        output.pop()

# 出力
print(*list(output))
 from sys import stdin from collections import deque n = int(input()) n int(input()) int input() input command = stdin command stdin output = deque([]) output deque([]) deque [] for a in command:
    if a[0] == 'i':
        output.appendleft(int(a[7:]))
    elif a[0:7] == 'delete ':
        try:
            output.remove(int(a[7:]))
        except ValueError:
            pass
    elif a[6] == 'F':
        output.popleft()
    else:
        output.pop()

# 出力 a command if a[0] == 'i':
        output.appendleft(int(a[7:]))
    elif a[0:7] == 'delete ':
        try:
            output.remove(int(a[7:]))
        except ValueError:
            pass
    elif a[6] == 'F':
        output.popleft()
    else:
        output.pop()

# 出力 a[0] == 'i' a[0] a 0 'i' output.appendleft(int(a[7:])) output.appendleft output appendleft int(a[7:]) int a[7:] a 7: 7 elif a[0:7] == 'delete ':
        try:
            output.remove(int(a[7:]))
        except ValueError:
            pass
     a[0:7] == 'delete ' a[0:7] a 0:7 0 7 'delete ' try:
            output.remove(int(a[7:]))
        except ValueError:
            pass
     except ValueError:
            pass
     output.remove(int(a[7:])) output.remove output remove int(a[7:]) int a[7:] a 7: 7 elif a[6] == 'F':
        output.popleft()
     a[6] == 'F' a[6] a 6 'F' output.popleft() output.popleft output popleft output.pop() output.pop output pop print(*list(output)) print *list(output) list(output) list output output = deque([]) deque([]) output n = int(input()) int(input()) n command = stdin stdin command
from sys import stdin
from collections import deque

# 入力
n = int(input())

# command = [stdin.readline()[:-1] for a in range(n)]
command = stdin

# process
output = deque([])

for a in command:
    if a[0] == 'i':
        output.appendleft(int(a[7:]))
    elif a[0:7] == 'delete ':
        try:
            output.remove(int(a[7:]))
        except ValueError:
            pass
    elif a[6] == 'F':
        output.popleft()
    else:
        output.pop()

# 出力
print(*list(output))

