n = int(raw_input())
L = []
c = 0
for i in xrange(n):
    cmd = raw_input()
    if cmd[0] == "i":
        L.append(cmd[7:])
    elif cmd[6] == " ":
        try:
            L.pop(~L[::-1].index(cmd[7:]))
        except:
            pass
    elif cmd[6] == "F":
        L.pop()
    else:
        c += 1

print " ".join(map(str, L[c:][::-1])) n = int(raw_input()) n int(raw_input()) int raw_input() raw_input L = [] L [] c = 0 c 0 for i in xrange(n):
    cmd = raw_input()
    if cmd[0] == "i":
        L.append(cmd[7:])
    elif cmd[6] == " ":
        try:
            L.pop(~L[::-1].index(cmd[7:]))
        except:
            pass
    elif cmd[6] == "F":
        L.pop()
    else:
        c += 1 i xrange(n) xrange n cmd = raw_input() cmd raw_input() raw_input if cmd[0] == "i":
        L.append(cmd[7:])
    elif cmd[6] == " ":
        try:
            L.pop(~L[::-1].index(cmd[7:]))
        except:
            pass
    elif cmd[6] == "F":
        L.pop()
    else:
        c += 1 cmd[0] == "i" cmd[0] cmd 0 "i" L.append(cmd[7:]) L.append L append cmd[7:] cmd 7: 7 elif cmd[6] == " ":
        try:
            L.pop(~L[::-1].index(cmd[7:]))
        except:
            pass
     cmd[6] == " " cmd[6] cmd 6 " " try:
            L.pop(~L[::-1].index(cmd[7:]))
        except:
            pass
     except:
            pass
     L.pop(~L[::-1].index(cmd[7:])) L.pop L pop ~L[::-1].index(cmd[7:]) L[::-1].index(cmd[7:]) [::-1].index [::-1] L ::-1 -1 index cmd[7:] cmd 7: 7 elif cmd[6] == "F":
        L.pop()
     cmd[6] == "F" cmd[6] cmd 6 "F" L.pop() L.pop L pop c += 1 c 1 print " ".join(map(str, L[c:][::-1])) " ".join " " join map(str, L[c:][::-1]) map str L[c:][::-1] [c:] L c: c ::-1 -1 n = int(raw_input()) int(raw_input()) n c = 0 0 c c += 1 1 c L = [] [] L cmd = raw_input() raw_input() cmd
n = int(raw_input())
L = []
c = 0
for i in xrange(n):
    cmd = raw_input()
    if cmd[0] == "i":
        L.append(cmd[7:])
    elif cmd[6] == " ":
        try:
            L.pop(~L[::-1].index(cmd[7:]))
        except:
            pass
    elif cmd[6] == "F":
        L.pop()
    else:
        c += 1

print " ".join(map(str, L[c:][::-1]))