n = int(raw_input())
q = []
bottom = 0
for i in range(n):
    cmd = raw_input()
    if cmd[0] == 'i':
        q.append(cmd[7:])
    elif cmd[6] == ' ':
        try:
            q.pop(~q[::-1].index(cmd[7:]))
        except:
            pass
    elif cmd[6] == 'F':
        q.pop()
    else:
        bottom += 1

print(' '.join(q[bottom:][::-1])) n = int(raw_input()) n int(raw_input()) int raw_input() raw_input q = [] q [] bottom = 0 bottom 0 for i in range(n):
    cmd = raw_input()
    if cmd[0] == 'i':
        q.append(cmd[7:])
    elif cmd[6] == ' ':
        try:
            q.pop(~q[::-1].index(cmd[7:]))
        except:
            pass
    elif cmd[6] == 'F':
        q.pop()
    else:
        bottom += 1 i range(n) range n cmd = raw_input() cmd raw_input() raw_input if cmd[0] == 'i':
        q.append(cmd[7:])
    elif cmd[6] == ' ':
        try:
            q.pop(~q[::-1].index(cmd[7:]))
        except:
            pass
    elif cmd[6] == 'F':
        q.pop()
    else:
        bottom += 1 cmd[0] == 'i' cmd[0] cmd 0 'i' q.append(cmd[7:]) q.append q append cmd[7:] cmd 7: 7 elif cmd[6] == ' ':
        try:
            q.pop(~q[::-1].index(cmd[7:]))
        except:
            pass
     cmd[6] == ' ' cmd[6] cmd 6 ' ' try:
            q.pop(~q[::-1].index(cmd[7:]))
        except:
            pass
     except:
            pass
     q.pop(~q[::-1].index(cmd[7:])) q.pop q pop ~q[::-1].index(cmd[7:]) q[::-1].index(cmd[7:]) [::-1].index [::-1] q ::-1 -1 index cmd[7:] cmd 7: 7 elif cmd[6] == 'F':
        q.pop()
     cmd[6] == 'F' cmd[6] cmd 6 'F' q.pop() q.pop q pop bottom += 1 bottom 1 print(' '.join(q[bottom:][::-1])) print ' '.join(q[bottom:][::-1]) ' '.join ' ' join q[bottom:][::-1] [bottom:] q bottom: bottom ::-1 -1 bottom = 0 0 bottom q = [] [] q bottom += 1 1 bottom cmd = raw_input() raw_input() cmd n = int(raw_input()) int(raw_input()) n
n = int(raw_input())
q = []
bottom = 0
for i in range(n):
    cmd = raw_input()
    if cmd[0] == 'i':
        q.append(cmd[7:])
    elif cmd[6] == ' ':
        try:
            q.pop(~q[::-1].index(cmd[7:]))
        except:
            pass
    elif cmd[6] == 'F':
        q.pop()
    else:
        bottom += 1

print(' '.join(q[bottom:][::-1]))