from collections import deque
import sys
input = sys.stdin.readline
n = int(input())
d = deque()
for _ in range(n):
    l = input().strip()
    if "deleteFirst" == l:d.popleft();continue
    elif "deleteLast" == l: d.pop();continue
    c, s = l.split()
    if c == "insert": d.appendleft(s);continue
    elif s in d: d.remove(s)
print(*d) from collections import deque import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline n = int(input()) n int(input()) int input() input d = deque() d deque() deque for _ in range(n):
    l = input().strip()
    if "deleteFirst" == l:d.popleft();continue
    elif "deleteLast" == l: d.pop();continue
    c, s = l.split()
    if c == "insert": d.appendleft(s);continue
    elif s in d: d.remove(s) _ range(n) range n l = input().strip() l input().strip() ().strip () input strip if "deleteFirst" == l:d.popleft();continue
    elif "deleteLast" == l: d.pop();continue
     "deleteFirst" == l "deleteFirst" l elif "deleteLast" == l: d.pop();continue
     "deleteLast" == l "deleteLast" l c, s = l.split() c l.split() l.split l split s if c == "insert": d.appendleft(s);continue
    elif s in d: d.remove(s) c == "insert" c "insert" elif s in d: d.remov s in d s d print(*d) print *d d input = sys.stdin.readline sys.stdin.readline input s = l.split() l.split() s c, s = l.split() l.split() c d = deque() deque() d n = int(input()) int(input()) n l = input().strip() input().strip() l
from collections import deque
import sys
input = sys.stdin.readline
n = int(input())
d = deque()
for _ in range(n):
    l = input().strip()
    if "deleteFirst" == l:d.popleft();continue
    elif "deleteLast" == l: d.pop();continue
    c, s = l.split()
    if c == "insert": d.appendleft(s);continue
    elif s in d: d.remove(s)
print(*d)
