# -*- coding:utf8 -*-

from collections import deque
n = int(input())
c = [input() for _ in range(n)]
d = deque()

for com in c:
    if com[0] == 'i':
        d.appendleft(com[7:])
    else:
        s = com[6]
        if s == 'F':
            d.popleft()
        elif s == 'L':
            d.pop()
        else:
            try:
                d.remove(com[7:])
            except ValueError:
                pass
print(' '.join(d))
 from collections import deque n = int(input()) n int(input()) int input() input input() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) input() input c = [input() for _ in range(n)] c [input() for _ in range(n)] d = deque() d deque() deque for com in c:
    if com[0] == 'i':
        d.appendleft(com[7:])
    else:
        s = com[6]
        if s == 'F':
            d.popleft()
        elif s == 'L':
            d.pop()
        else:
            try:
                d.remove(com[7:])
            except ValueError:
                pass com c if com[0] == 'i':
        d.appendleft(com[7:])
    else:
        s = com[6]
        if s == 'F':
            d.popleft()
        elif s == 'L':
            d.pop()
        else:
            try:
                d.remove(com[7:])
            except ValueError:
                pass com[0] == 'i' com[0] com 0 'i' d.appendleft(com[7:]) d.appendleft d appendleft com[7:] com 7: 7 s = com[6] s com[6] com 6 if s == 'F':
            d.popleft()
        elif s == 'L':
            d.pop()
        else:
            try:
                d.remove(com[7:])
            except ValueError:
                pass s == 'F' s 'F' d.popleft() d.popleft d popleft elif s == 'L':
            d.pop()
         s == 'L' s 'L' d.pop() d.pop d pop try:
                d.remove(com[7:])
            except ValueError:
                pass except ValueError:
                pass d.remove(com[7:]) d.remove d remove com[7:] com 7: 7 print(' '.join(d)) print ' '.join(d) ' '.join ' ' join d d = deque() deque() d n = int(input()) int(input()) n c = [input() for _ in range(n)] [input() for _ in range(n)] c s = com[6] com[6] s
# -*- coding:utf8 -*-

from collections import deque
n = int(input())
c = [input() for _ in range(n)]
d = deque()

for com in c:
    if com[0] == 'i':
        d.appendleft(com[7:])
    else:
        s = com[6]
        if s == 'F':
            d.popleft()
        elif s == 'L':
            d.pop()
        else:
            try:
                d.remove(com[7:])
            except ValueError:
                pass
print(' '.join(d))

