import collections
N=int(input())
A=collections.deque()
for i in range(N):
    c=input()
    if c[0]=='i':
        A.appendleft(int(c.split()[1]))
    elif c[6]==' ':
        if int(c.split()[1]) in A:
            A.remove(int(c.split()[1]))
    elif c[6]=='F':
        A.popleft()
    elif c[6]=='L':
        A.pop()
print(*A) import collections collections N=int(input()) N int(input()) int input() input A=collections.deque() A collections.deque() collections.deque collections deque for i in range(N):
    c=input()
    if c[0]=='i':
        A.appendleft(int(c.split()[1]))
    elif c[6]==' ':
        if int(c.split()[1]) in A:
            A.remove(int(c.split()[1]))
    elif c[6]=='F':
        A.popleft()
    elif c[6]=='L':
        A.pop() i range(N) range N c=input() c input() input if c[0]=='i':
        A.appendleft(int(c.split()[1]))
    elif c[6]==' ':
        if int(c.split()[1]) in A:
            A.remove(int(c.split()[1]))
    elif c[6]=='F':
        A.popleft()
    elif c[6]=='L':
        A.pop() c[0]=='i' c[0] c 0 'i' A.appendleft(int(c.split()[1])) A.appendleft A appendleft int(c.split()[1]) int c.split()[1] c.split() c.split c split 1 elif c[6]==' ':
        if int(c.split()[1]) in A:
            A.remove(int(c.split()[1]))
     c[6]==' ' c[6] c 6 ' ' if int(c.split()[1]) in A:
            A.remove(int(c.split()[1]))
     int(c.split()[1]) in A int(c.split()[1]) int c.split()[1] c.split() c.split c split 1 A A.remove(int(c.split()[1])) A.remove A remove int(c.split()[1]) int c.split()[1] c.split() c.split c split 1 elif c[6]=='F':
        A.popleft()
     c[6]=='F' c[6] c 6 'F' A.popleft() A.popleft A popleft elif c[6]=='L':
        A.pop() c[6]=='L' c[6] c 6 'L' A.pop() A.pop A pop print(*A) print *A A A=collections.deque() collections.deque() A c=input() input() c N=int(input()) int(input()) N
import collections
N=int(input())
A=collections.deque()
for i in range(N):
    c=input()
    if c[0]=='i':
        A.appendleft(int(c.split()[1]))
    elif c[6]==' ':
        if int(c.split()[1]) in A:
            A.remove(int(c.split()[1]))
    elif c[6]=='F':
        A.popleft()
    elif c[6]=='L':
        A.pop()
print(*A)
