from collections import deque

n=int(input())
l=deque()
for i in range(n):
    com=input()
    if(com=="deleteFirst"):
        l.popleft()
    elif(com=="deleteLast"):
        l.pop()
    else:
        com,val=com.split()
        if(com=="insert"):
            l.appendleft(val)
        elif(com=="delete"):
            try:
                l.remove(val)
            except:
                pass

print(' '.join(l))
 from collections import deque n=int(input()) n int(input()) int input() input l=deque() l deque() deque for i in range(n):
    com=input()
    if(com=="deleteFirst"):
        l.popleft()
    elif(com=="deleteLast"):
        l.pop()
    else:
        com,val=com.split()
        if(com=="insert"):
            l.appendleft(val)
        elif(com=="delete"):
            try:
                l.remove(val)
            except:
                pass i range(n) range n com=input() com input() input if(com=="deleteFirst"):
        l.popleft()
    elif(com=="deleteLast"):
        l.pop()
    else:
        com,val=com.split()
        if(com=="insert"):
            l.appendleft(val)
        elif(com=="delete"):
            try:
                l.remove(val)
            except:
                pass com=="deleteFirst" com "deleteFirst" l.popleft() l.popleft l popleft elif(com=="deleteLast"):
        l.pop()
     com=="deleteLast" com "deleteLast" l.pop() l.pop l pop com,val=com.split() com com.split() com.split com split val if(com=="insert"):
            l.appendleft(val)
        elif(com=="delete"):
            try:
                l.remove(val)
            except:
                pass com=="insert" com "insert" l.appendleft(val) l.appendleft l appendleft val elif(com=="delete"):
            try:
                l.remove(val)
            except:
                pass com=="delete" com "delete" try:
                l.remove(val)
            except:
                pass except:
                pass l.remove(val) l.remove l remove val print(' '.join(l)) print ' '.join(l) ' '.join ' ' join l n=int(input()) int(input()) n com,val=com.split() com.split() com val=com.split() com.split() val l=deque() deque() l com=input() input() com
from collections import deque

n=int(input())
l=deque()
for i in range(n):
    com=input()
    if(com=="deleteFirst"):
        l.popleft()
    elif(com=="deleteLast"):
        l.pop()
    else:
        com,val=com.split()
        if(com=="insert"):
            l.appendleft(val)
        elif(com=="delete"):
            try:
                l.remove(val)
            except:
                pass

print(' '.join(l))

