from collections import deque
from sys import stdin
q = deque()
input()
for s in stdin:
    if s == '\n':
        break
    c, *k = s.split()
    k = k[0] if k else None
    if c == 'insert':
        q.appendleft(k)
    elif c == 'delete':
        if k in q:
            q.remove(k)
    elif c == 'deleteFirst':
        q.popleft()
    else:
        q.pop()
print(*q) from collections import deque from sys import stdin q = deque() q deque() deque input() input for s in stdin:
    if s == '\n':
        break
    c, *k = s.split()
    k = k[0] if k else None
    if c == 'insert':
        q.appendleft(k)
    elif c == 'delete':
        if k in q:
            q.remove(k)
    elif c == 'deleteFirst':
        q.popleft()
    else:
        q.pop() s stdin if s == '\n':
        break
     s == '\n' s '\n' break c, *k = s.split() c s.split() s.split s split *k k k = k[0] if k else None k k[0] if k else None k k[0] k 0 None if c == 'insert':
        q.appendleft(k)
    elif c == 'delete':
        if k in q:
            q.remove(k)
    elif c == 'deleteFirst':
        q.popleft()
    else:
        q.pop() c == 'insert' c 'insert' q.appendleft(k) q.appendleft q appendleft k elif c == 'delete':
        if k in q:
            q.remove(k)
     c == 'delete' c 'delete' if k in q:
            q.remove(k)
     k in q k q q.remove(k) q.remove q remove k elif c == 'deleteFirst':
        q.popleft()
     c == 'deleteFirst' c 'deleteFirst' q.popleft() q.popleft q popleft q.pop() q.pop q pop print(*q) print *q q c, *k = s.split() s.split() c q = deque() deque() q k = k[0] if k else None k[0] if k else None k
from collections import deque
from sys import stdin
q = deque()
input()
for s in stdin:
    if s == '\n':
        break
    c, *k = s.split()
    k = k[0] if k else None
    if c == 'insert':
        q.appendleft(k)
    elif c == 'delete':
        if k in q:
            q.remove(k)
    elif c == 'deleteFirst':
        q.popleft()
    else:
        q.pop()
print(*q)
