from collections import deque
n = int(input())

d = deque()

for _ in range(n):
    com = input()
    if (com[0] == 'i'):
        com ,i = com.split()
        d.appendleft(int(i))
    elif (com[0] == 'd'):
        if (com[6] == ' '):
            com, i = com.split()
            try:
                d.remove(int(i))
            except ValueError:
                pass
        elif (com[6] == 'F'):
            d.popleft()
        elif (com[6] == 'L'):
            d.pop()
ans = map(str, d)
ans = " ".join(ans)
print(ans) from collections import deque n = int(input()) n int(input()) int input() input d = deque() d deque() deque for _ in range(n):
    com = input()
    if (com[0] == 'i'):
        com ,i = com.split()
        d.appendleft(int(i))
    elif (com[0] == 'd'):
        if (com[6] == ' '):
            com, i = com.split()
            try:
                d.remove(int(i))
            except ValueError:
                pass
        elif (com[6] == 'F'):
            d.popleft()
        elif (com[6] == 'L'):
            d.pop() _ range(n) range n com = input() com input() input if (com[0] == 'i'):
        com ,i = com.split()
        d.appendleft(int(i))
    elif (com[0] == 'd'):
        if (com[6] == ' '):
            com, i = com.split()
            try:
                d.remove(int(i))
            except ValueError:
                pass
        elif (com[6] == 'F'):
            d.popleft()
        elif (com[6] == 'L'):
            d.pop() com[0] == 'i' com[0] com 0 'i' com ,i = com.split() com com.split() com.split com split i d.appendleft(int(i)) d.appendleft d appendleft int(i) int i elif (com[0] == 'd'):
        if (com[6] == ' '):
            com, i = com.split()
            try:
                d.remove(int(i))
            except ValueError:
                pass
        elif (com[6] == 'F'):
            d.popleft()
        elif (com[6] == 'L'):
            d.pop() com[0] == 'd' com[0] com 0 'd' if (com[6] == ' '):
            com, i = com.split()
            try:
                d.remove(int(i))
            except ValueError:
                pass
        elif (com[6] == 'F'):
            d.popleft()
        elif (com[6] == 'L'):
            d.pop() com[6] == ' ' com[6] com 6 ' ' com, i = com.split() com com.split() com.split com split i try:
                d.remove(int(i))
            except ValueError:
                pass
         except ValueError:
                pass
         d.remove(int(i)) d.remove d remove int(i) int i elif (com[6] == 'F'):
            d.popleft()
         com[6] == 'F' com[6] com 6 'F' d.popleft() d.popleft d popleft elif (com[6] == 'L'):
            d.pop() com[6] == 'L' com[6] com 6 'L' d.pop() d.pop d pop ans = map(str, d) ans map(str, d) map str d ans = " ".join(ans) ans " ".join(ans) " ".join " " join ans print(ans) print ans ans = map(str, d) map(str, d) ans i = com.split() com.split() i d = deque() deque() d com, i = com.split() com.split() com ans = " ".join(ans) " ".join(ans) ans n = int(input()) int(input()) n com = input() input() com com ,i = com.split() com.split() com i = com.split() com.split() i
from collections import deque
n = int(input())

d = deque()

for _ in range(n):
    com = input()
    if (com[0] == 'i'):
        com ,i = com.split()
        d.appendleft(int(i))
    elif (com[0] == 'd'):
        if (com[6] == ' '):
            com, i = com.split()
            try:
                d.remove(int(i))
            except ValueError:
                pass
        elif (com[6] == 'F'):
            d.popleft()
        elif (com[6] == 'L'):
            d.pop()
ans = map(str, d)
ans = " ".join(ans)
print(ans)