from collections import deque

q = deque()

n = int(input().strip())

for _ in range(n):
    cmd = input()
    if cmd == "deleteFirst":
        q.popleft()
    elif cmd == "deleteLast":
        q.pop()
    elif cmd.startswith("insert "):
        v = cmd[7:]
        q.appendleft(v)
    elif cmd.startswith("delete "):
        v = cmd[7:]
        try:
            q.remove(v)
        except ValueError:
            pass
print(" ".join(q)) from collections import deque q = deque() q deque() deque n = int(input().strip()) n int(input().strip()) int input().strip() ().strip () input strip for _ in range(n):
    cmd = input()
    if cmd == "deleteFirst":
        q.popleft()
    elif cmd == "deleteLast":
        q.pop()
    elif cmd.startswith("insert "):
        v = cmd[7:]
        q.appendleft(v)
    elif cmd.startswith("delete "):
        v = cmd[7:]
        try:
            q.remove(v)
        except ValueError:
            pass _ range(n) range n cmd = input() cmd input() input if cmd == "deleteFirst":
        q.popleft()
    elif cmd == "deleteLast":
        q.pop()
    elif cmd.startswith("insert "):
        v = cmd[7:]
        q.appendleft(v)
    elif cmd.startswith("delete "):
        v = cmd[7:]
        try:
            q.remove(v)
        except ValueError:
            pass cmd == "deleteFirst" cmd "deleteFirst" q.popleft() q.popleft q popleft elif cmd == "deleteLast":
        q.pop()
     cmd == "deleteLast" cmd "deleteLast" q.pop() q.pop q pop elif cmd.startswith("insert "):
        v = cmd[7:]
        q.appendleft(v)
     cmd.startswith("insert ") cmd.startswith cmd startswith "insert " v = cmd[7:] v cmd[7:] cmd 7: 7 q.appendleft(v) q.appendleft q appendleft v elif cmd.startswith("delete "):
        v = cmd[7:]
        try:
            q.remove(v)
        except ValueError:
            pass cmd.startswith("delete ") cmd.startswith cmd startswith "delete " v = cmd[7:] v cmd[7:] cmd 7: 7 try:
            q.remove(v)
        except ValueError:
            pass except ValueError:
            pass q.remove(v) q.remove q remove v print(" ".join(q)) print " ".join(q) " ".join " " join q v = cmd[7:] cmd[7:] v cmd = input() input() cmd v = cmd[7:] cmd[7:] v n = int(input().strip()) int(input().strip()) n q = deque() deque() q
from collections import deque

q = deque()

n = int(input().strip())

for _ in range(n):
    cmd = input()
    if cmd == "deleteFirst":
        q.popleft()
    elif cmd == "deleteLast":
        q.pop()
    elif cmd.startswith("insert "):
        v = cmd[7:]
        q.appendleft(v)
    elif cmd.startswith("delete "):
        v = cmd[7:]
        try:
            q.remove(v)
        except ValueError:
            pass
print(" ".join(q))