import sys
from collections import deque

def main():
    A = deque()
    input()
    for e in sys.stdin:
        if e[0]=='i': #insert xxx
            A.appendleft(e[7:-1])
        else:
            if e[6]==' ': #delete xxx
                m = e[7:-1]
                if m in A: 
                    A.remove(m)
            elif e[6]=='F':
                A.popleft()
            else:
                A.pop()
    print(' '.join(A))

if __name__=='__main__':
    main() import sys sys from collections import deque def main():
    A = deque()
    input()
    for e in sys.stdin:
        if e[0]=='i': #insert xxx
            A.appendleft(e[7:-1])
        else:
            if e[6]==' ': #delete xxx
                m = e[7:-1]
                if m in A: 
                    A.remove(m)
            elif e[6]=='F':
                A.popleft()
            else:
                A.pop()
    print(' '.join(A)) main A = deque() A deque() deque input() input for e in sys.stdin:
        if e[0]=='i': #insert xxx
            A.appendleft(e[7:-1])
        else:
            if e[6]==' ': #delete xxx
                m = e[7:-1]
                if m in A: 
                    A.remove(m)
            elif e[6]=='F':
                A.popleft()
            else:
                A.pop()
     e sys.stdin sys stdin if e[0]=='i': #insert xxx
            A.appendleft(e[7:-1])
        else:
            if e[6]==' ': #delete xxx
                m = e[7:-1]
                if m in A: 
                    A.remove(m)
            elif e[6]=='F':
                A.popleft()
            else:
                A.pop()
     e[0]=='i' e[0] e 0 'i' A.appendleft(e[7:-1]) A.appendleft A appendleft e[7:-1] e 7:-1 7 -1 if e[6]==' ': #delete xxx
                m = e[7:-1]
                if m in A: 
                    A.remove(m)
            elif e[6]=='F':
                A.popleft()
            else:
                A.pop()
     e[6]==' ' e[6] e 6 ' ' m = e[7:-1] m e[7:-1] e 7:-1 7 -1 if m in A: 
                    A.remove(m)
             m in A m A A.remove(m) A.remove A remove m elif e[6]=='F':
                A.popleft()
             e[6]=='F' e[6] e 6 'F' A.popleft() A.popleft A popleft A.pop() A.pop A pop print(' '.join(A)) print ' '.join(A) ' '.join ' ' join A if __name__=='__main__':
    main() __name__=='__main__' __name__ '__main__' main() main def main():
    A = deque()
    input()
    for e in sys.stdin:
        if e[0]=='i': #insert xxx
            A.appendleft(e[7:-1])
        else:
            if e[6]==' ': #delete xxx
                m = e[7:-1]
                if m in A: 
                    A.remove(m)
            elif e[6]=='F':
                A.popleft()
            else:
                A.pop()
    print(' '.join(A)) def main():
    A = deque()
    input()
    for e in sys.stdin:
        if e[0]=='i': #insert xxx
            A.appendleft(e[7:-1])
        else:
            if e[6]==' ': #delete xxx
                m = e[7:-1]
                if m in A: 
                    A.remove(m)
            elif e[6]=='F':
                A.popleft()
            else:
                A.pop()
    print(' '.join(A)) main
import sys
from collections import deque

def main():
    A = deque()
    input()
    for e in sys.stdin:
        if e[0]=='i': #insert xxx
            A.appendleft(e[7:-1])
        else:
            if e[6]==' ': #delete xxx
                m = e[7:-1]
                if m in A: 
                    A.remove(m)
            elif e[6]=='F':
                A.popleft()
            else:
                A.pop()
    print(' '.join(A))

if __name__=='__main__':
    main()
