from collections import deque
q=deque()
n=int(input())

for i in range(n):
    cmd=input()
    if cmd=="deleteFirst":
        try:
            q.popleft()
        except:
            pass
        
    elif cmd=="deleteLast":
        try:
            q.pop()
        except:
            pass
        
    else:
        cmd,number=cmd.split()
        if cmd=="delete":
            try:
                q.remove(number)
            except:
                pass
            
        elif cmd=="insert":
            q.appendleft(number)
        
print(*q) from collections import deque q=deque() q deque() deque n=int(input()) n int(input()) int input() input for i in range(n):
    cmd=input()
    if cmd=="deleteFirst":
        try:
            q.popleft()
        except:
            pass
        
    elif cmd=="deleteLast":
        try:
            q.pop()
        except:
            pass
        
    else:
        cmd,number=cmd.split()
        if cmd=="delete":
            try:
                q.remove(number)
            except:
                pass
            
        elif cmd=="insert":
            q.appendleft(number)
         i range(n) range n cmd=input() cmd input() input if cmd=="deleteFirst":
        try:
            q.popleft()
        except:
            pass
        
    elif cmd=="deleteLast":
        try:
            q.pop()
        except:
            pass
        
    else:
        cmd,number=cmd.split()
        if cmd=="delete":
            try:
                q.remove(number)
            except:
                pass
            
        elif cmd=="insert":
            q.appendleft(number)
         cmd=="deleteFirst" cmd "deleteFirst" try:
            q.popleft()
        except:
            pass
        
     except:
            pass
        
     q.popleft() q.popleft q popleft elif cmd=="deleteLast":
        try:
            q.pop()
        except:
            pass
        
     cmd=="deleteLast" cmd "deleteLast" try:
            q.pop()
        except:
            pass
        
     except:
            pass
        
     q.pop() q.pop q pop cmd,number=cmd.split() cmd cmd.split() cmd.split cmd split number if cmd=="delete":
            try:
                q.remove(number)
            except:
                pass
            
        elif cmd=="insert":
            q.appendleft(number)
         cmd=="delete" cmd "delete" try:
                q.remove(number)
            except:
                pass
            
         except:
                pass
            
         q.remove(number) q.remove q remove number elif cmd=="insert":
            q.appendleft(number)
         cmd=="insert" cmd "insert" q.appendleft(number) q.appendleft q appendleft number print(*q) print *q q cmd,number=cmd.split() cmd.split() cmd cmd=input() input() cmd q=deque() deque() q number=cmd.split() cmd.split() number n=int(input()) int(input()) n
from collections import deque
q=deque()
n=int(input())

for i in range(n):
    cmd=input()
    if cmd=="deleteFirst":
        try:
            q.popleft()
        except:
            pass
        
    elif cmd=="deleteLast":
        try:
            q.pop()
        except:
            pass
        
    else:
        cmd,number=cmd.split()
        if cmd=="delete":
            try:
                q.remove(number)
            except:
                pass
            
        elif cmd=="insert":
            q.appendleft(number)
        
print(*q)
