n = input()
lis = []
bot = 0
for i in xrange(n):
    com = raw_input()
    if   com[0] == 'i':
        lis.append(com[7:])
    elif com[6] == ' ':
        try:
            lis.pop(~lis[::-1].index(com[7:]))
        except:
            pass
    elif com[6] == 'F':
        lis.pop()
    else:
        bot += 1

print ' '.join( map(str, reversed(lis[bot:])) ) n = input() n input() input lis = [] lis [] bot = 0 bot 0 for i in xrange(n):
    com = raw_input()
    if   com[0] == 'i':
        lis.append(com[7:])
    elif com[6] == ' ':
        try:
            lis.pop(~lis[::-1].index(com[7:]))
        except:
            pass
    elif com[6] == 'F':
        lis.pop()
    else:
        bot += 1 i xrange(n) xrange n com = raw_input() com raw_input() raw_input if   com[0] == 'i':
        lis.append(com[7:])
    elif com[6] == ' ':
        try:
            lis.pop(~lis[::-1].index(com[7:]))
        except:
            pass
    elif com[6] == 'F':
        lis.pop()
    else:
        bot += 1 com[0] == 'i' com[0] com 0 'i' lis.append(com[7:]) lis.append lis append com[7:] com 7: 7 elif com[6] == ' ':
        try:
            lis.pop(~lis[::-1].index(com[7:]))
        except:
            pass
     com[6] == ' ' com[6] com 6 ' ' try:
            lis.pop(~lis[::-1].index(com[7:]))
        except:
            pass
     except:
            pass
     lis.pop(~lis[::-1].index(com[7:])) lis.pop lis pop ~lis[::-1].index(com[7:]) lis[::-1].index(com[7:]) [::-1].index [::-1] lis ::-1 -1 index com[7:] com 7: 7 elif com[6] == 'F':
        lis.pop()
     com[6] == 'F' com[6] com 6 'F' lis.pop() lis.pop lis pop bot += 1 bot 1 print ' '.join( map(str, reversed(lis[bot:])) ) ' '.join ' ' join map(str, reversed(lis[bot:])) map str reversed(lis[bot:]) reversed lis[bot:] lis bot: bot bot = 0 0 bot bot += 1 1 bot lis = [] [] lis com = raw_input() raw_input() com n = input() input() n
n = input()
lis = []
bot = 0
for i in xrange(n):
    com = raw_input()
    if   com[0] == 'i':
        lis.append(com[7:])
    elif com[6] == ' ':
        try:
            lis.pop(~lis[::-1].index(com[7:]))
        except:
            pass
    elif com[6] == 'F':
        lis.pop()
    else:
        bot += 1

print ' '.join( map(str, reversed(lis[bot:])) )