from collections import deque
from sys import stdin
q = deque()
input()
for s in stdin:
    c, *k = s.split()
    k = k[0] if k else None
    if c[0] == 'i':
        q.appendleft(k)
    elif c[0] == 'd':
        if c[6:7] == 'F':
            q.popleft()
        elif c[6:7] == 'L':
            q.pop()
        else:
            if k in q:
                q.remove(k)
print(*q) from collections import deque from sys import stdin q = deque() q deque() deque input() input for s in stdin:
    c, *k = s.split()
    k = k[0] if k else None
    if c[0] == 'i':
        q.appendleft(k)
    elif c[0] == 'd':
        if c[6:7] == 'F':
            q.popleft()
        elif c[6:7] == 'L':
            q.pop()
        else:
            if k in q:
                q.remove(k) s stdin 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[0] == 'i':
        q.appendleft(k)
    elif c[0] == 'd':
        if c[6:7] == 'F':
            q.popleft()
        elif c[6:7] == 'L':
            q.pop()
        else:
            if k in q:
                q.remove(k) c[0] == 'i' c[0] c 0 'i' q.appendleft(k) q.appendleft q appendleft k elif c[0] == 'd':
        if c[6:7] == 'F':
            q.popleft()
        elif c[6:7] == 'L':
            q.pop()
        else:
            if k in q:
                q.remove(k) c[0] == 'd' c[0] c 0 'd' if c[6:7] == 'F':
            q.popleft()
        elif c[6:7] == 'L':
            q.pop()
        else:
            if k in q:
                q.remove(k) c[6:7] == 'F' c[6:7] c 6:7 6 7 'F' q.popleft() q.popleft q popleft elif c[6:7] == 'L':
            q.pop()
         c[6:7] == 'L' c[6:7] c 6:7 6 7 'L' q.pop() q.pop q pop if k in q:
                q.remove(k) k in q k q q.remove(k) q.remove q remove k print(*q) print *q q k = k[0] if k else None k[0] if k else None k c, *k = s.split() s.split() c q = deque() deque() q
from collections import deque
from sys import stdin
q = deque()
input()
for s in stdin:
    c, *k = s.split()
    k = k[0] if k else None
    if c[0] == 'i':
        q.appendleft(k)
    elif c[0] == 'd':
        if c[6:7] == 'F':
            q.popleft()
        elif c[6:7] == 'L':
            q.pop()
        else:
            if k in q:
                q.remove(k)
print(*q)
