from collections import deque

n = int(input())
Q = deque()
for _ in range(n):
    query = input()
    if query=='deleteFirst':
        Q.popleft()
    elif query=='deleteLast':
        Q.pop()
    else:
        q, x = query.split()
        if q=='insert':
            Q.appendleft(x)
        else:
            try:
                Q.remove(x)
            except ValueError:
                pass

print(' '.join(Q)) from collections import deque n = int(input()) n int(input()) int input() input Q = deque() Q deque() deque for _ in range(n):
    query = input()
    if query=='deleteFirst':
        Q.popleft()
    elif query=='deleteLast':
        Q.pop()
    else:
        q, x = query.split()
        if q=='insert':
            Q.appendleft(x)
        else:
            try:
                Q.remove(x)
            except ValueError:
                pass _ range(n) range n query = input() query input() input if query=='deleteFirst':
        Q.popleft()
    elif query=='deleteLast':
        Q.pop()
    else:
        q, x = query.split()
        if q=='insert':
            Q.appendleft(x)
        else:
            try:
                Q.remove(x)
            except ValueError:
                pass query=='deleteFirst' query 'deleteFirst' Q.popleft() Q.popleft Q popleft elif query=='deleteLast':
        Q.pop()
     query=='deleteLast' query 'deleteLast' Q.pop() Q.pop Q pop q, x = query.split() q query.split() query.split query split x if q=='insert':
            Q.appendleft(x)
        else:
            try:
                Q.remove(x)
            except ValueError:
                pass q=='insert' q 'insert' Q.appendleft(x) Q.appendleft Q appendleft x try:
                Q.remove(x)
            except ValueError:
                pass except ValueError:
                pass Q.remove(x) Q.remove Q remove x print(' '.join(Q)) print ' '.join(Q) ' '.join ' ' join Q n = int(input()) int(input()) n q, x = query.split() query.split() q x = query.split() query.split() x query = input() input() query Q = deque() deque() Q
from collections import deque

n = int(input())
Q = deque()
for _ in range(n):
    query = input()
    if query=='deleteFirst':
        Q.popleft()
    elif query=='deleteLast':
        Q.pop()
    else:
        q, x = query.split()
        if q=='insert':
            Q.appendleft(x)
        else:
            try:
                Q.remove(x)
            except ValueError:
                pass

print(' '.join(Q))
