from collections import deque
n=int(raw_input())
q = deque()
for i in xrange(n):
    o = raw_input()
    if o == 'deleteFirst':  q.popleft()
    elif o == 'deleteLast': q.pop()
    else:
        c,p = o.split(); p = int(p)
        if c == 'insert': q.appendleft(p)
        elif c == 'delete':
            try: q.remove(p)
            except: pass
print ' '.join(map(str,q)) from collections import deque n=int(raw_input()) n int(raw_input()) int raw_input() raw_input q = deque() q deque() deque for i in xrange(n):
    o = raw_input()
    if o == 'deleteFirst':  q.popleft()
    elif o == 'deleteLast': q.pop()
    else:
        c,p = o.split(); p = int(p)
        if c == 'insert': q.appendleft(p)
        elif c == 'delete':
            try: q.remove(p)
            except: pass i xrange(n) xrange n o = raw_input() o raw_input() raw_input if o == 'deleteFirst':  q.popleft()
    elif o == 'deleteLast': q.pop()
    else:
        c,p = o.split(); p = int(p)
        if c == 'insert': q.appendleft(p)
        elif c == 'delete':
            try: q.remove(p)
            except: pass o == 'deleteFirst' o 'deleteFirst' elif o == 'deleteLast': q.pop()
     o == 'deleteLast' o 'deleteLast' c,p = o.split() c o.split() o.split o split p p = int(p) p int(p) int p if c == 'insert': q.appendleft(p)
        elif c == 'delete':
            try: q.remove(p)
            except: pass c == 'insert' c 'insert' elif c == 'delete':
            try: q.remove(p)
            except: pass c == 'delete' c 'delete' try: q.remove(p)
            except: pass print ' '.join(map(str,q)) ' '.join ' ' join map(str,q) map str q q = deque() deque() q c,p = o.split() o.split() c n=int(raw_input()) int(raw_input()) n o = raw_input() raw_input() o p = int(p) int(p) p p = o.split() o.split() p
from collections import deque
n=int(raw_input())
q = deque()
for i in xrange(n):
    o = raw_input()
    if o == 'deleteFirst':  q.popleft()
    elif o == 'deleteLast': q.pop()
    else:
        c,p = o.split(); p = int(p)
        if c == 'insert': q.appendleft(p)
        elif c == 'delete':
            try: q.remove(p)
            except: pass
print ' '.join(map(str,q))