from collections import deque
d = deque()
for a in range(int(input())):
    com = input().split()
    if com[0] == "insert":
        d.appendleft(com[1])
    elif com[0] == "delete":
        if com[1] in d:
            d.remove(com[1])
    elif com[0] == "deleteFirst":
        d.popleft()
    elif com[0] == "deleteLast":
        d.pop()
    else:
        break
print(*d)
 from collections import deque d = deque() d deque() deque for a in range(int(input())):
    com = input().split()
    if com[0] == "insert":
        d.appendleft(com[1])
    elif com[0] == "delete":
        if com[1] in d:
            d.remove(com[1])
    elif com[0] == "deleteFirst":
        d.popleft()
    elif com[0] == "deleteLast":
        d.pop()
    else:
        break a range(int(input())) range int(input()) int input() input com = input().split() com input().split() ().split () input split if com[0] == "insert":
        d.appendleft(com[1])
    elif com[0] == "delete":
        if com[1] in d:
            d.remove(com[1])
    elif com[0] == "deleteFirst":
        d.popleft()
    elif com[0] == "deleteLast":
        d.pop()
    else:
        break com[0] == "insert" com[0] com 0 "insert" d.appendleft(com[1]) d.appendleft d appendleft com[1] com 1 elif com[0] == "delete":
        if com[1] in d:
            d.remove(com[1])
     com[0] == "delete" com[0] com 0 "delete" if com[1] in d:
            d.remove(com[1])
     com[1] in d com[1] com 1 d d.remove(com[1]) d.remove d remove com[1] com 1 elif com[0] == "deleteFirst":
        d.popleft()
     com[0] == "deleteFirst" com[0] com 0 "deleteFirst" d.popleft() d.popleft d popleft elif com[0] == "deleteLast":
        d.pop()
     com[0] == "deleteLast" com[0] com 0 "deleteLast" d.pop() d.pop d pop break print(*d) print *d d com = input().split() input().split() com d = deque() deque() d
from collections import deque
d = deque()
for a in range(int(input())):
    com = input().split()
    if com[0] == "insert":
        d.appendleft(com[1])
    elif com[0] == "delete":
        if com[1] in d:
            d.remove(com[1])
    elif com[0] == "deleteFirst":
        d.popleft()
    elif com[0] == "deleteLast":
        d.pop()
    else:
        break
print(*d)

