from sys import stdin
from collections import deque
input = stdin.readline

# 自作dequeでは実行時間的に通らないので...

n = int(input())
d: deque = deque([])

for _ in range(n):
    command = input().split()

    if command[0] == "insert":
        x = int(command[1])
        d.appendleft(x)

    elif command[0] == "delete":
        x = int(command[1])
        if d.count(x):
            d.remove(x)

    elif command[0] == "deleteFirst":
        tmp = d.popleft()

    elif command[0] == "deleteLast":
        tmp = d.pop()

while d:
    tmp = d.popleft()

    if d:
        print(tmp, end=" ")
    else:
        print(tmp)
 from sys import stdin from collections import deque input = stdin.readline input stdin.readline stdin readline n = int(input()) n int(input()) int input() input d: deque = deque([]) d deque([]) deque [] for _ in range(n):
    command = input().split()

    if command[0] == "insert":
        x = int(command[1])
        d.appendleft(x)

    elif command[0] == "delete":
        x = int(command[1])
        if d.count(x):
            d.remove(x)

    elif command[0] == "deleteFirst":
        tmp = d.popleft()

    elif command[0] == "deleteLast":
        tmp = d.pop() _ range(n) range n command = input().split() command input().split() ().split () input split if command[0] == "insert":
        x = int(command[1])
        d.appendleft(x)

    elif command[0] == "delete":
        x = int(command[1])
        if d.count(x):
            d.remove(x)

    elif command[0] == "deleteFirst":
        tmp = d.popleft()

    elif command[0] == "deleteLast":
        tmp = d.pop() command[0] == "insert" command[0] command 0 "insert" x = int(command[1]) x int(command[1]) int command[1] command 1 d.appendleft(x) d.appendleft d appendleft x elif command[0] == "delete":
        x = int(command[1])
        if d.count(x):
            d.remove(x)

     command[0] == "delete" command[0] command 0 "delete" x = int(command[1]) x int(command[1]) int command[1] command 1 if d.count(x):
            d.remove(x)

     d.count(x) d.count d count x d.remove(x) d.remove d remove x elif command[0] == "deleteFirst":
        tmp = d.popleft()

     command[0] == "deleteFirst" command[0] command 0 "deleteFirst" tmp = d.popleft() tmp d.popleft() d.popleft d popleft elif command[0] == "deleteLast":
        tmp = d.pop() command[0] == "deleteLast" command[0] command 0 "deleteLast" tmp = d.pop() tmp d.pop() d.pop d pop while d:
    tmp = d.popleft()

    if d:
        print(tmp, end=" ")
    else:
        print(tmp) d tmp = d.popleft() tmp d.popleft() d.popleft d popleft if d:
        print(tmp, end=" ")
    else:
        print(tmp) d print(tmp, end=" ") print tmp end=" " end " " print(tmp) print tmp d: deque = deque([]) deque([]) d n = int(input()) int(input()) n input = stdin.readline stdin.readline input command = input().split() input().split() command tmp = d.popleft() d.popleft() tmp x = int(command[1]) int(command[1]) x x = int(command[1]) int(command[1]) x tmp = d.popleft() d.popleft() tmp tmp = d.pop() d.pop() tmp
from sys import stdin
from collections import deque
input = stdin.readline

# 自作dequeでは実行時間的に通らないので...

n = int(input())
d: deque = deque([])

for _ in range(n):
    command = input().split()

    if command[0] == "insert":
        x = int(command[1])
        d.appendleft(x)

    elif command[0] == "delete":
        x = int(command[1])
        if d.count(x):
            d.remove(x)

    elif command[0] == "deleteFirst":
        tmp = d.popleft()

    elif command[0] == "deleteLast":
        tmp = d.pop()

while d:
    tmp = d.popleft()

    if d:
        print(tmp, end=" ")
    else:
        print(tmp)

