from collections import deque
N = int(input())

x_list=deque()

for i in range(N):
    a = input().split()
    if a[0] == "insert":
        x_list.appendleft(a[1])
    elif a[0] == "delete":
        try:
            x_list.remove(a[1])
        except:
            pass
    elif a[0] == "deleteFirst":
        x_list.popleft()
    else:
        x_list.pop()

print(*x_list) from collections import deque N = int(input()) N int(input()) int input() input x_list=deque() x_list deque() deque for i in range(N):
    a = input().split()
    if a[0] == "insert":
        x_list.appendleft(a[1])
    elif a[0] == "delete":
        try:
            x_list.remove(a[1])
        except:
            pass
    elif a[0] == "deleteFirst":
        x_list.popleft()
    else:
        x_list.pop() i range(N) range N a = input().split() a input().split() ().split () input split if a[0] == "insert":
        x_list.appendleft(a[1])
    elif a[0] == "delete":
        try:
            x_list.remove(a[1])
        except:
            pass
    elif a[0] == "deleteFirst":
        x_list.popleft()
    else:
        x_list.pop() a[0] == "insert" a[0] a 0 "insert" x_list.appendleft(a[1]) x_list.appendleft x_list appendleft a[1] a 1 elif a[0] == "delete":
        try:
            x_list.remove(a[1])
        except:
            pass
     a[0] == "delete" a[0] a 0 "delete" try:
            x_list.remove(a[1])
        except:
            pass
     except:
            pass
     x_list.remove(a[1]) x_list.remove x_list remove a[1] a 1 elif a[0] == "deleteFirst":
        x_list.popleft()
     a[0] == "deleteFirst" a[0] a 0 "deleteFirst" x_list.popleft() x_list.popleft x_list popleft x_list.pop() x_list.pop x_list pop print(*x_list) print *x_list x_list N = int(input()) int(input()) N a = input().split() input().split() a x_list=deque() deque() x_list
from collections import deque
N = int(input())

x_list=deque()

for i in range(N):
    a = input().split()
    if a[0] == "insert":
        x_list.appendleft(a[1])
    elif a[0] == "delete":
        try:
            x_list.remove(a[1])
        except:
            pass
    elif a[0] == "deleteFirst":
        x_list.popleft()
    else:
        x_list.pop()

print(*x_list)
