from collections import deque

def pr(a):
    for i in range(len(a)):
        if i == len(a)-1:
            print(a[i])
        else:
            print(a[i],end = " ")

n = int(input())
q = deque()
for i in range(n):
    x = input()
    l = len(x)
    if x[0] == "i":
        q.insert(0,x[7:])
    elif x[6] == " ":
        try:
            q.remove(x[7:])
        except:
            pass
    elif l > 10:
        q.popleft()
    elif l > 6:
        q.pop()

print(*q) from collections import deque def pr(a):
    for i in range(len(a)):
        if i == len(a)-1:
            print(a[i])
        else:
            print(a[i],end = " ") pr for i in range(len(a)):
        if i == len(a)-1:
            print(a[i])
        else:
            print(a[i],end = " ") i range(len(a)) range len(a) len a if i == len(a)-1:
            print(a[i])
        else:
            print(a[i],end = " ") i == len(a)-1 i len(a)-1 len(a) len a 1 print(a[i]) print a[i] a i print(a[i],end = " ") print a[i] a i end = " " end " " a a n = int(input()) n int(input()) int input() input q = deque() q deque() deque for i in range(n):
    x = input()
    l = len(x)
    if x[0] == "i":
        q.insert(0,x[7:])
    elif x[6] == " ":
        try:
            q.remove(x[7:])
        except:
            pass
    elif l > 10:
        q.popleft()
    elif l > 6:
        q.pop() i range(n) range n x = input() x input() input l = len(x) l len(x) len x if x[0] == "i":
        q.insert(0,x[7:])
    elif x[6] == " ":
        try:
            q.remove(x[7:])
        except:
            pass
    elif l > 10:
        q.popleft()
    elif l > 6:
        q.pop() x[0] == "i" x[0] x 0 "i" q.insert(0,x[7:]) q.insert q insert 0 x[7:] x 7: 7 elif x[6] == " ":
        try:
            q.remove(x[7:])
        except:
            pass
     x[6] == " " x[6] x 6 " " try:
            q.remove(x[7:])
        except:
            pass
     except:
            pass
     q.remove(x[7:]) q.remove q remove x[7:] x 7: 7 elif l > 10:
        q.popleft()
     l > 10 l 10 q.popleft() q.popleft q popleft elif l > 6:
        q.pop() l > 6 l 6 q.pop() q.pop q pop print(*q) print *q q def pr(a):
    for i in range(len(a)):
        if i == len(a)-1:
            print(a[i])
        else:
            print(a[i],end = " ") def pr(a):
    for i in range(len(a)):
        if i == len(a)-1:
            print(a[i])
        else:
            print(a[i],end = " ") pr q = deque() deque() q x = input() input() x n = int(input()) int(input()) n l = len(x) len(x) l
from collections import deque

def pr(a):
    for i in range(len(a)):
        if i == len(a)-1:
            print(a[i])
        else:
            print(a[i],end = " ")

n = int(input())
q = deque()
for i in range(n):
    x = input()
    l = len(x)
    if x[0] == "i":
        q.insert(0,x[7:])
    elif x[6] == " ":
        try:
            q.remove(x[7:])
        except:
            pass
    elif l > 10:
        q.popleft()
    elif l > 6:
        q.pop()

print(*q)
