from collections import deque

n = int(input())
commands = [input() for _ in range(n)] # splitとかしてると間に合わない

l = deque()
for com in commands:
    if com[0]=='i':
        l.appendleft(com[7:])
    elif com[6]=='F':
        l.popleft()
    elif com[6]=='L':
        l.pop()
    else:
        try:
            l.remove(com[7:])
        except:
            pass

s = ' '.join(l)
print(s) 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 commands = [input() for _ in range(n)] commands [input() for _ in range(n)] l = deque() l deque() deque for com in commands:
    if com[0]=='i':
        l.appendleft(com[7:])
    elif com[6]=='F':
        l.popleft()
    elif com[6]=='L':
        l.pop()
    else:
        try:
            l.remove(com[7:])
        except:
            pass com commands if com[0]=='i':
        l.appendleft(com[7:])
    elif com[6]=='F':
        l.popleft()
    elif com[6]=='L':
        l.pop()
    else:
        try:
            l.remove(com[7:])
        except:
            pass com[0]=='i' com[0] com 0 'i' l.appendleft(com[7:]) l.appendleft l appendleft com[7:] com 7: 7 elif com[6]=='F':
        l.popleft()
     com[6]=='F' com[6] com 6 'F' l.popleft() l.popleft l popleft elif com[6]=='L':
        l.pop()
     com[6]=='L' com[6] com 6 'L' l.pop() l.pop l pop try:
            l.remove(com[7:])
        except:
            pass except:
            pass l.remove(com[7:]) l.remove l remove com[7:] com 7: 7 s = ' '.join(l) s ' '.join(l) ' '.join ' ' join l print(s) print s s = ' '.join(l) ' '.join(l) s commands = [input() for _ in range(n)] [input() for _ in range(n)] commands l = deque() deque() l n = int(input()) int(input()) n
from collections import deque

n = int(input())
commands = [input() for _ in range(n)] # splitとかしてると間に合わない

l = deque()
for com in commands:
    if com[0]=='i':
        l.appendleft(com[7:])
    elif com[6]=='F':
        l.popleft()
    elif com[6]=='L':
        l.pop()
    else:
        try:
            l.remove(com[7:])
        except:
            pass

s = ' '.join(l)
print(s)
