import collections
hoge = collections.deque()
n = int(input())
for _ in range(n):
    commands = input().split()
    if len(commands) == 1:
        if commands[0] == 'deleteFirst':
            hoge.popleft()
        else:
            hoge.pop()
    else:
        com, x = commands
        if com == 'insert':
            hoge.insert(0, x)
        else:
            if x in hoge:
                hoge.remove(x)
print (' '.join(hoge)) import collections collections hoge = collections.deque() hoge collections.deque() collections.deque collections deque n = int(input()) n int(input()) int input() input for _ in range(n):
    commands = input().split()
    if len(commands) == 1:
        if commands[0] == 'deleteFirst':
            hoge.popleft()
        else:
            hoge.pop()
    else:
        com, x = commands
        if com == 'insert':
            hoge.insert(0, x)
        else:
            if x in hoge:
                hoge.remove(x) _ range(n) range n commands = input().split() commands input().split() ().split () input split if len(commands) == 1:
        if commands[0] == 'deleteFirst':
            hoge.popleft()
        else:
            hoge.pop()
    else:
        com, x = commands
        if com == 'insert':
            hoge.insert(0, x)
        else:
            if x in hoge:
                hoge.remove(x) len(commands) == 1 len(commands) len commands 1 if commands[0] == 'deleteFirst':
            hoge.popleft()
        else:
            hoge.pop()
     commands[0] == 'deleteFirst' commands[0] commands 0 'deleteFirst' hoge.popleft() hoge.popleft hoge popleft hoge.pop() hoge.pop hoge pop com, x = commands com commands x if com == 'insert':
            hoge.insert(0, x)
        else:
            if x in hoge:
                hoge.remove(x) com == 'insert' com 'insert' hoge.insert(0, x) hoge.insert hoge insert 0 x if x in hoge:
                hoge.remove(x) x in hoge x hoge hoge.remove(x) hoge.remove hoge remove x print (' '.join(hoge)) print ' '.join(hoge) ' '.join ' ' join hoge hoge = collections.deque() collections.deque() hoge commands = input().split() input().split() commands n = int(input()) int(input()) n com, x = commands commands com x = commands commands x
import collections
hoge = collections.deque()
n = int(input())
for _ in range(n):
    commands = input().split()
    if len(commands) == 1:
        if commands[0] == 'deleteFirst':
            hoge.popleft()
        else:
            hoge.pop()
    else:
        com, x = commands
        if com == 'insert':
            hoge.insert(0, x)
        else:
            if x in hoge:
                hoge.remove(x)
print (' '.join(hoge))
