import sys
from collections import deque
n = int(sys.stdin.readline())

ans = deque()

for i in range(n):
    c = sys.stdin.readline()[:-1]
    if c[0] == 'i':
        ans.appendleft(c[7:])
    elif c[6] == ' ':
        try:
            ans.remove(c[7:])
        except:
            pass
    elif c[6] == 'F':
        ans.popleft()
    else:
        ans.pop()

print(' '.join(ans)) import sys sys from collections import deque n = int(sys.stdin.readline()) n int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline ans = deque() ans deque() deque for i in range(n):
    c = sys.stdin.readline()[:-1]
    if c[0] == 'i':
        ans.appendleft(c[7:])
    elif c[6] == ' ':
        try:
            ans.remove(c[7:])
        except:
            pass
    elif c[6] == 'F':
        ans.popleft()
    else:
        ans.pop() i range(n) range n c = sys.stdin.readline()[:-1] c sys.stdin.readline()[:-1] sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline :-1 -1 if c[0] == 'i':
        ans.appendleft(c[7:])
    elif c[6] == ' ':
        try:
            ans.remove(c[7:])
        except:
            pass
    elif c[6] == 'F':
        ans.popleft()
    else:
        ans.pop() c[0] == 'i' c[0] c 0 'i' ans.appendleft(c[7:]) ans.appendleft ans appendleft c[7:] c 7: 7 elif c[6] == ' ':
        try:
            ans.remove(c[7:])
        except:
            pass
     c[6] == ' ' c[6] c 6 ' ' try:
            ans.remove(c[7:])
        except:
            pass
     except:
            pass
     ans.remove(c[7:]) ans.remove ans remove c[7:] c 7: 7 elif c[6] == 'F':
        ans.popleft()
     c[6] == 'F' c[6] c 6 'F' ans.popleft() ans.popleft ans popleft ans.pop() ans.pop ans pop print(' '.join(ans)) print ' '.join(ans) ' '.join ' ' join ans c = sys.stdin.readline()[:-1] sys.stdin.readline()[:-1] c n = int(sys.stdin.readline()) int(sys.stdin.readline()) n ans = deque() deque() ans
import sys
from collections import deque
n = int(sys.stdin.readline())

ans = deque()

for i in range(n):
    c = sys.stdin.readline()[:-1]
    if c[0] == 'i':
        ans.appendleft(c[7:])
    elif c[6] == ' ':
        try:
            ans.remove(c[7:])
        except:
            pass
    elif c[6] == 'F':
        ans.popleft()
    else:
        ans.pop()

print(' '.join(ans))