
from collections import deque
import sys

d=deque()

n=int(input())

for i in range(n):
    s=input()
    if s=='deleteFirst':
        d.popleft()
    elif s=='deleteLast':
        d.pop()
    else:
        ss,num=s.split()
        if ss == 'insert':
            d.appendleft(num)
        else:
            try:
                d.remove(num)
            except:
                pass

print(' '.join(d))

"""
def main():
    num2 = 5
    plus(num2)
    print(num2)

def plus(num2):
    num2 += 2
    return num2

if __name__=="__main__":
    main()
    """ from collections import deque import sys sys d=deque() d deque() deque n=int(input()) n int(input()) int input() input for i in range(n):
    s=input()
    if s=='deleteFirst':
        d.popleft()
    elif s=='deleteLast':
        d.pop()
    else:
        ss,num=s.split()
        if ss == 'insert':
            d.appendleft(num)
        else:
            try:
                d.remove(num)
            except:
                pass i range(n) range n s=input() s input() input if s=='deleteFirst':
        d.popleft()
    elif s=='deleteLast':
        d.pop()
    else:
        ss,num=s.split()
        if ss == 'insert':
            d.appendleft(num)
        else:
            try:
                d.remove(num)
            except:
                pass s=='deleteFirst' s 'deleteFirst' d.popleft() d.popleft d popleft elif s=='deleteLast':
        d.pop()
     s=='deleteLast' s 'deleteLast' d.pop() d.pop d pop ss,num=s.split() ss s.split() s.split s split num if ss == 'insert':
            d.appendleft(num)
        else:
            try:
                d.remove(num)
            except:
                pass ss == 'insert' ss 'insert' d.appendleft(num) d.appendleft d appendleft num try:
                d.remove(num)
            except:
                pass except:
                pass d.remove(num) d.remove d remove num print(' '.join(d)) print ' '.join(d) ' '.join ' ' join d """
def main():
    num2 = 5
    plus(num2)
    print(num2)

def plus(num2):
    num2 += 2
    return num2

if __name__=="__main__":
    main()
    """ d=deque() deque() d ss,num=s.split() s.split() ss num=s.split() s.split() num n=int(input()) int(input()) n s=input() input() s

from collections import deque
import sys

d=deque()

n=int(input())

for i in range(n):
    s=input()
    if s=='deleteFirst':
        d.popleft()
    elif s=='deleteLast':
        d.pop()
    else:
        ss,num=s.split()
        if ss == 'insert':
            d.appendleft(num)
        else:
            try:
                d.remove(num)
            except:
                pass

print(' '.join(d))

"""
def main():
    num2 = 5
    plus(num2)
    print(num2)

def plus(num2):
    num2 += 2
    return num2

if __name__=="__main__":
    main()
    """
