class Element:
    def __init__(self, x):
        self.x = x
        self.lh = None
        self.rh = None

class MyDeque:
    def __init__(self):
        self.top = self.tail = None
    
    def insert(self, x):
        elm = Element(x)
        if self.top is None:
            self.top = self.tail = elm
        else:
            elm.rh = self.top
            self.top.lh = self.top = elm
        
    def delete(self, x):
        elm = self.top
        while elm is not None:
            if elm.x == x:
                if elm.lh is None and elm.rh is None:
                    self.top = self.tail = None
                else:    
                    if elm.lh is None:
                        self.top = elm.rh
                    else:
                        elm.lh.rh = elm.rh
                        
                    if elm.rh is None:
                        self.tail = elm.lh
                    else:
                        elm.rh.lh = elm.lh
                break
            
            elm = elm.rh
            
    def delete_first(self):
        if self.top is self.tail:
            self.top = self.tail = None
        else:
            self.top = self.top.rh
            self.top.lh = None
                
    def delete_last(self):
        if self.top is self.tail:
            self.top = self.tail = None
        else:
            self.tail = self.tail.lh
            self.tail.rh = None
                
    
    def print_que(self):
        elm = self.top
        q=[]
        while elm is not None:
            q.append(elm.x)
            elm = elm.rh
        print(*q)

from sys import stdin

que = MyDeque()
N = int(input())
for _ in range(N):
    cmd = stdin.readline().strip().split()
    if cmd[0] == 'insert':
        que.insert(cmd[1])
        #que.print_que()        
        
    elif cmd[0] == 'delete':
        que.delete(cmd[1])
        #que.print_que()
        
    elif cmd[0] == 'deleteFirst':
        que.delete_first()
        #que.print_que()
        
    elif cmd[0] == 'deleteLast':
        que.delete_last()
        #que.print_que()
    
que.print_que() class Element:
    def __init__(self, x):
        self.x = x
        self.lh = None
        self.rh = None Element def __init__(self, x):
        self.x = x
        self.lh = None
        self.rh = None __init__ self.x = x self.x self x x self.lh = None self.lh self lh None self.rh = None self.rh self rh None self self x x class MyDeque:
    def __init__(self):
        self.top = self.tail = None
    
    def insert(self, x):
        elm = Element(x)
        if self.top is None:
            self.top = self.tail = elm
        else:
            elm.rh = self.top
            self.top.lh = self.top = elm
        
    def delete(self, x):
        elm = self.top
        while elm is not None:
            if elm.x == x:
                if elm.lh is None and elm.rh is None:
                    self.top = self.tail = None
                else:    
                    if elm.lh is None:
                        self.top = elm.rh
                    else:
                        elm.lh.rh = elm.rh
                        
                    if elm.rh is None:
                        self.tail = elm.lh
                    else:
                        elm.rh.lh = elm.lh
                break
            
            elm = elm.rh
            
    def delete_first(self):
        if self.top is self.tail:
            self.top = self.tail = None
        else:
            self.top = self.top.rh
            self.top.lh = None
                
    def delete_last(self):
        if self.top is self.tail:
            self.top = self.tail = None
        else:
            self.tail = self.tail.lh
            self.tail.rh = None
                
    
    def print_que(self):
        elm = self.top
        q=[]
        while elm is not None:
            q.append(elm.x)
            elm = elm.rh
        print(*q) MyDeque def __init__(self):
        self.top = self.tail = None
    
     __init__ self.top = self.tail = None self.top self top None = self.tail = None self.tail self tail None self self def insert(self, x):
        elm = Element(x)
        if self.top is None:
            self.top = self.tail = elm
        else:
            elm.rh = self.top
            self.top.lh = self.top = elm
        
     insert elm = Element(x) elm Element(x) Element x if self.top is None:
            self.top = self.tail = elm
        else:
            elm.rh = self.top
            self.top.lh = self.top = elm
        
     self.top is None self.top self top None self.top = self.tail = elm self.top self top elm = self.tail = elm self.tail self tail elm elm.rh = self.top elm.rh elm rh self.top self top self.top.lh = self.top = elm self.top.lh self.top self top lh elm = self.top = elm self.top self top elm self self x x def delete(self, x):
        elm = self.top
        while elm is not None:
            if elm.x == x:
                if elm.lh is None and elm.rh is None:
                    self.top = self.tail = None
                else:    
                    if elm.lh is None:
                        self.top = elm.rh
                    else:
                        elm.lh.rh = elm.rh
                        
                    if elm.rh is None:
                        self.tail = elm.lh
                    else:
                        elm.rh.lh = elm.lh
                break
            
            elm = elm.rh
            
     delete elm = self.top elm self.top self top while elm is not None:
            if elm.x == x:
                if elm.lh is None and elm.rh is None:
                    self.top = self.tail = None
                else:    
                    if elm.lh is None:
                        self.top = elm.rh
                    else:
                        elm.lh.rh = elm.rh
                        
                    if elm.rh is None:
                        self.tail = elm.lh
                    else:
                        elm.rh.lh = elm.lh
                break
            
            elm = elm.rh
            
     elm is not None elm None if elm.x == x:
                if elm.lh is None and elm.rh is None:
                    self.top = self.tail = None
                else:    
                    if elm.lh is None:
                        self.top = elm.rh
                    else:
                        elm.lh.rh = elm.rh
                        
                    if elm.rh is None:
                        self.tail = elm.lh
                    else:
                        elm.rh.lh = elm.lh
                break
            
             elm.x == x elm.x elm x x if elm.lh is None and elm.rh is None:
                    self.top = self.tail = None
                else:    
                    if elm.lh is None:
                        self.top = elm.rh
                    else:
                        elm.lh.rh = elm.rh
                        
                    if elm.rh is None:
                        self.tail = elm.lh
                    else:
                        elm.rh.lh = elm.lh
                 elm.lh is None and elm.rh is None elm.lh is None elm.lh elm lh None elm.rh is None elm.rh elm rh None self.top = self.tail = None self.top self top None = self.tail = None self.tail self tail None if elm.lh is None:
                        self.top = elm.rh
                    else:
                        elm.lh.rh = elm.rh
                        
                     elm.lh is None elm.lh elm lh None self.top = elm.rh self.top self top elm.rh elm rh elm.lh.rh = elm.rh elm.lh.rh elm.lh elm lh rh elm.rh elm rh if elm.rh is None:
                        self.tail = elm.lh
                    else:
                        elm.rh.lh = elm.lh
                 elm.rh is None elm.rh elm rh None self.tail = elm.lh self.tail self tail elm.lh elm lh elm.rh.lh = elm.lh elm.rh.lh elm.rh elm rh lh elm.lh elm lh break elm = elm.rh elm elm.rh elm rh self self x x def delete_first(self):
        if self.top is self.tail:
            self.top = self.tail = None
        else:
            self.top = self.top.rh
            self.top.lh = None
                
     delete_first if self.top is self.tail:
            self.top = self.tail = None
        else:
            self.top = self.top.rh
            self.top.lh = None
                
     self.top is self.tail self.top self top self.tail self tail self.top = self.tail = None self.top self top None = self.tail = None self.tail self tail None self.top = self.top.rh self.top self top self.top.rh self.top self top rh self.top.lh = None self.top.lh self.top self top lh None self self def delete_last(self):
        if self.top is self.tail:
            self.top = self.tail = None
        else:
            self.tail = self.tail.lh
            self.tail.rh = None
                
    
     delete_last if self.top is self.tail:
            self.top = self.tail = None
        else:
            self.tail = self.tail.lh
            self.tail.rh = None
                
    
     self.top is self.tail self.top self top self.tail self tail self.top = self.tail = None self.top self top None = self.tail = None self.tail self tail None self.tail = self.tail.lh self.tail self tail self.tail.lh self.tail self tail lh self.tail.rh = None self.tail.rh self.tail self tail rh None self self def print_que(self):
        elm = self.top
        q=[]
        while elm is not None:
            q.append(elm.x)
            elm = elm.rh
        print(*q) print_que elm = self.top elm self.top self top q=[] q [] while elm is not None:
            q.append(elm.x)
            elm = elm.rh
         elm is not None elm None q.append(elm.x) q.append q append elm.x elm x elm = elm.rh elm elm.rh elm rh print(*q) print *q q self self from sys import stdin que = MyDeque() que MyDeque() MyDeque N = int(input()) N int(input()) int input() input for _ in range(N):
    cmd = stdin.readline().strip().split()
    if cmd[0] == 'insert':
        que.insert(cmd[1])
        #que.print_que()        
        
    elif cmd[0] == 'delete':
        que.delete(cmd[1])
        #que.print_que()
        
    elif cmd[0] == 'deleteFirst':
        que.delete_first()
        #que.print_que()
        
    elif cmd[0] == 'deleteLast':
        que.delete_last()
        #que.print_que()
     _ range(N) range N cmd = stdin.readline().strip().split() cmd stdin.readline().strip().split() stdin.readline().strip().split stdin.readline().strip() stdin.readline().strip stdin.readline() stdin.readline stdin readline strip split if cmd[0] == 'insert':
        que.insert(cmd[1])
        #que.print_que()        
        
    elif cmd[0] == 'delete':
        que.delete(cmd[1])
        #que.print_que()
        
    elif cmd[0] == 'deleteFirst':
        que.delete_first()
        #que.print_que()
        
    elif cmd[0] == 'deleteLast':
        que.delete_last()
        #que.print_que()
     cmd[0] == 'insert' cmd[0] cmd 0 'insert' que.insert(cmd[1]) que.insert que insert cmd[1] cmd 1 elif cmd[0] == 'delete':
        que.delete(cmd[1])
        #que.print_que()
        
     cmd[0] == 'delete' cmd[0] cmd 0 'delete' que.delete(cmd[1]) que.delete que delete cmd[1] cmd 1 elif cmd[0] == 'deleteFirst':
        que.delete_first()
        #que.print_que()
        
     cmd[0] == 'deleteFirst' cmd[0] cmd 0 'deleteFirst' que.delete_first() que.delete_first que delete_first elif cmd[0] == 'deleteLast':
        que.delete_last()
        #que.print_que()
     cmd[0] == 'deleteLast' cmd[0] cmd 0 'deleteLast' que.delete_last() que.delete_last que delete_last que.print_que() que.print_que que print_que N = int(input()) int(input()) N class Element:
    def __init__(self, x):
        self.x = x
        self.lh = None
        self.rh = None class Element:
    def __init__(self, x):
        self.x = x
        self.lh = None
        self.rh = None Element que = MyDeque() MyDeque() que cmd = stdin.readline().strip().split() stdin.readline().strip().split() cmd class MyDeque:
    def __init__(self):
        self.top = self.tail = None
    
    def insert(self, x):
        elm = Element(x)
        if self.top is None:
            self.top = self.tail = elm
        else:
            elm.rh = self.top
            self.top.lh = self.top = elm
        
    def delete(self, x):
        elm = self.top
        while elm is not None:
            if elm.x == x:
                if elm.lh is None and elm.rh is None:
                    self.top = self.tail = None
                else:    
                    if elm.lh is None:
                        self.top = elm.rh
                    else:
                        elm.lh.rh = elm.rh
                        
                    if elm.rh is None:
                        self.tail = elm.lh
                    else:
                        elm.rh.lh = elm.lh
                break
            
            elm = elm.rh
            
    def delete_first(self):
        if self.top is self.tail:
            self.top = self.tail = None
        else:
            self.top = self.top.rh
            self.top.lh = None
                
    def delete_last(self):
        if self.top is self.tail:
            self.top = self.tail = None
        else:
            self.tail = self.tail.lh
            self.tail.rh = None
                
    
    def print_que(self):
        elm = self.top
        q=[]
        while elm is not None:
            q.append(elm.x)
            elm = elm.rh
        print(*q) class MyDeque:
    def __init__(self):
        self.top = self.tail = None
    
    def insert(self, x):
        elm = Element(x)
        if self.top is None:
            self.top = self.tail = elm
        else:
            elm.rh = self.top
            self.top.lh = self.top = elm
        
    def delete(self, x):
        elm = self.top
        while elm is not None:
            if elm.x == x:
                if elm.lh is None and elm.rh is None:
                    self.top = self.tail = None
                else:    
                    if elm.lh is None:
                        self.top = elm.rh
                    else:
                        elm.lh.rh = elm.rh
                        
                    if elm.rh is None:
                        self.tail = elm.lh
                    else:
                        elm.rh.lh = elm.lh
                break
            
            elm = elm.rh
            
    def delete_first(self):
        if self.top is self.tail:
            self.top = self.tail = None
        else:
            self.top = self.top.rh
            self.top.lh = None
                
    def delete_last(self):
        if self.top is self.tail:
            self.top = self.tail = None
        else:
            self.tail = self.tail.lh
            self.tail.rh = None
                
    
    def print_que(self):
        elm = self.top
        q=[]
        while elm is not None:
            q.append(elm.x)
            elm = elm.rh
        print(*q) MyDeque
class Element:
    def __init__(self, x):
        self.x = x
        self.lh = None
        self.rh = None

class MyDeque:
    def __init__(self):
        self.top = self.tail = None
    
    def insert(self, x):
        elm = Element(x)
        if self.top is None:
            self.top = self.tail = elm
        else:
            elm.rh = self.top
            self.top.lh = self.top = elm
        
    def delete(self, x):
        elm = self.top
        while elm is not None:
            if elm.x == x:
                if elm.lh is None and elm.rh is None:
                    self.top = self.tail = None
                else:    
                    if elm.lh is None:
                        self.top = elm.rh
                    else:
                        elm.lh.rh = elm.rh
                        
                    if elm.rh is None:
                        self.tail = elm.lh
                    else:
                        elm.rh.lh = elm.lh
                break
            
            elm = elm.rh
            
    def delete_first(self):
        if self.top is self.tail:
            self.top = self.tail = None
        else:
            self.top = self.top.rh
            self.top.lh = None
                
    def delete_last(self):
        if self.top is self.tail:
            self.top = self.tail = None
        else:
            self.tail = self.tail.lh
            self.tail.rh = None
                
    
    def print_que(self):
        elm = self.top
        q=[]
        while elm is not None:
            q.append(elm.x)
            elm = elm.rh
        print(*q)

from sys import stdin

que = MyDeque()
N = int(input())
for _ in range(N):
    cmd = stdin.readline().strip().split()
    if cmd[0] == 'insert':
        que.insert(cmd[1])
        #que.print_que()        
        
    elif cmd[0] == 'delete':
        que.delete(cmd[1])
        #que.print_que()
        
    elif cmd[0] == 'deleteFirst':
        que.delete_first()
        #que.print_que()
        
    elif cmd[0] == 'deleteLast':
        que.delete_last()
        #que.print_que()
    
que.print_que()
