from collections import deque
query = int(input())
l = deque()
for _ in range(query):
    command = input().strip()
    if command == "deleteFirst":
        try:
            l.popleft()
        except:
            pass
    elif command == "deleteLast":
        try:
            l.pop()
        except:
            pass
    else:
        command, value = command.split(" ")
        if command == "insert":
            l.appendleft(int(value))
        elif command == "delete":
            try:
                l.remove(int(value))
            except:
                pass
print(*l) from collections import deque query = int(input()) query int(input()) int input() input l = deque() l deque() deque for _ in range(query):
    command = input().strip()
    if command == "deleteFirst":
        try:
            l.popleft()
        except:
            pass
    elif command == "deleteLast":
        try:
            l.pop()
        except:
            pass
    else:
        command, value = command.split(" ")
        if command == "insert":
            l.appendleft(int(value))
        elif command == "delete":
            try:
                l.remove(int(value))
            except:
                pass _ range(query) range query command = input().strip() command input().strip() ().strip () input strip if command == "deleteFirst":
        try:
            l.popleft()
        except:
            pass
    elif command == "deleteLast":
        try:
            l.pop()
        except:
            pass
    else:
        command, value = command.split(" ")
        if command == "insert":
            l.appendleft(int(value))
        elif command == "delete":
            try:
                l.remove(int(value))
            except:
                pass command == "deleteFirst" command "deleteFirst" try:
            l.popleft()
        except:
            pass
     except:
            pass
     l.popleft() l.popleft l popleft elif command == "deleteLast":
        try:
            l.pop()
        except:
            pass
     command == "deleteLast" command "deleteLast" try:
            l.pop()
        except:
            pass
     except:
            pass
     l.pop() l.pop l pop command, value = command.split(" ") command command.split(" ") command.split command split " " value if command == "insert":
            l.appendleft(int(value))
        elif command == "delete":
            try:
                l.remove(int(value))
            except:
                pass command == "insert" command "insert" l.appendleft(int(value)) l.appendleft l appendleft int(value) int value elif command == "delete":
            try:
                l.remove(int(value))
            except:
                pass command == "delete" command "delete" try:
                l.remove(int(value))
            except:
                pass except:
                pass l.remove(int(value)) l.remove l remove int(value) int value print(*l) print *l l value = command.split(" ") command.split(" ") value command, value = command.split(" ") command.split(" ") command l = deque() deque() l query = int(input()) int(input()) query command = input().strip() input().strip() command
from collections import deque
query = int(input())
l = deque()
for _ in range(query):
    command = input().strip()
    if command == "deleteFirst":
        try:
            l.popleft()
        except:
            pass
    elif command == "deleteLast":
        try:
            l.pop()
        except:
            pass
    else:
        command, value = command.split(" ")
        if command == "insert":
            l.appendleft(int(value))
        elif command == "delete":
            try:
                l.remove(int(value))
            except:
                pass
print(*l)