# -*- coding: utf-8 -*-

from collections import deque

n = int(raw_input())
que = deque()
for i in range(n):
    com = str(raw_input())
    if com == "deleteFirst":
        del que[0]
    elif com == "deleteLast":
        del que[-1]
    else:
        c, p = com.split()
        if c == "insert":
            que.appendleft(p)
        else:
            try: que.remove(p)
            except: pass
print " ".join(map(str, que)) from collections import deque n = int(raw_input()) n int(raw_input()) int raw_input() raw_input que = deque() que deque() deque for i in range(n):
    com = str(raw_input())
    if com == "deleteFirst":
        del que[0]
    elif com == "deleteLast":
        del que[-1]
    else:
        c, p = com.split()
        if c == "insert":
            que.appendleft(p)
        else:
            try: que.remove(p)
            except: pass i range(n) range n com = str(raw_input()) com str(raw_input()) str raw_input() raw_input if com == "deleteFirst":
        del que[0]
    elif com == "deleteLast":
        del que[-1]
    else:
        c, p = com.split()
        if c == "insert":
            que.appendleft(p)
        else:
            try: que.remove(p)
            except: pass com == "deleteFirst" com "deleteFirst" del que[0] que[0] que 0 elif com == "deleteLast":
        del que[-1]
     com == "deleteLast" com "deleteLast" del que[-1] que[-1] que -1 c, p = com.split() c com.split() com.split com split p if c == "insert":
            que.appendleft(p)
        else:
            try: que.remove(p)
            except: pass c == "insert" c "insert" que.appendleft(p) que.appendleft que appendleft p try: que.remove(p)
            except: pass print " ".join(map(str, que)) " ".join " " join map(str, que) map str que p = com.split() com.split() p c, p = com.split() com.split() c que = deque() deque() que com = str(raw_input()) str(raw_input()) com n = int(raw_input()) int(raw_input()) n
# -*- coding: utf-8 -*-

from collections import deque

n = int(raw_input())
que = deque()
for i in range(n):
    com = str(raw_input())
    if com == "deleteFirst":
        del que[0]
    elif com == "deleteLast":
        del que[-1]
    else:
        c, p = com.split()
        if c == "insert":
            que.appendleft(p)
        else:
            try: que.remove(p)
            except: pass
print " ".join(map(str, que))