from collections import deque
x = deque()

for i in range(int(input())):
    com = input()
    if com == "deleteFirst":
        x.popleft()
    elif com == "deleteLast":
        x.pop()
    else:
        com,n = com.split()
        if com == "insert":
            x.appendleft(n)
        elif com == "delete":
            try:
                x.remove(n)
            except:
                pass
            
print(*x) from collections import deque x = deque() x deque() deque for i in range(int(input())):
    com = input()
    if com == "deleteFirst":
        x.popleft()
    elif com == "deleteLast":
        x.pop()
    else:
        com,n = com.split()
        if com == "insert":
            x.appendleft(n)
        elif com == "delete":
            try:
                x.remove(n)
            except:
                pass
             i range(int(input())) range int(input()) int input() input com = input() com input() input if com == "deleteFirst":
        x.popleft()
    elif com == "deleteLast":
        x.pop()
    else:
        com,n = com.split()
        if com == "insert":
            x.appendleft(n)
        elif com == "delete":
            try:
                x.remove(n)
            except:
                pass
             com == "deleteFirst" com "deleteFirst" x.popleft() x.popleft x popleft elif com == "deleteLast":
        x.pop()
     com == "deleteLast" com "deleteLast" x.pop() x.pop x pop com,n = com.split() com com.split() com.split com split n if com == "insert":
            x.appendleft(n)
        elif com == "delete":
            try:
                x.remove(n)
            except:
                pass
             com == "insert" com "insert" x.appendleft(n) x.appendleft x appendleft n elif com == "delete":
            try:
                x.remove(n)
            except:
                pass
             com == "delete" com "delete" try:
                x.remove(n)
            except:
                pass
             except:
                pass
             x.remove(n) x.remove x remove n print(*x) print *x x n = com.split() com.split() n x = deque() deque() x com = input() input() com com,n = com.split() com.split() com
from collections import deque
x = deque()

for i in range(int(input())):
    com = input()
    if com == "deleteFirst":
        x.popleft()
    elif com == "deleteLast":
        x.pop()
    else:
        com,n = com.split()
        if com == "insert":
            x.appendleft(n)
        elif com == "delete":
            try:
                x.remove(n)
            except:
                pass
            
print(*x)
