from collections import deque
from sys import stdin
n = int(input())
ddl = deque()
for i in stdin:
    inp = i.split()
    if len(inp) == 2:
        op, data = inp
        data = int(data)
    else: op, data = inp[0], None
    if op == 'insert':
        ddl.appendleft(data,)
    elif op == 'delete':
        try:
            ddl.remove(data)
        except ValueError:
            pass
    elif op == 'deleteFirst':
        ddl.popleft()
    elif op == 'deleteLast':
        ddl.pop()

print(' '.join([str(item) for item in ddl])) from collections import deque from sys import stdin n = int(input()) n int(input()) int input() input ddl = deque() ddl deque() deque for i in stdin:
    inp = i.split()
    if len(inp) == 2:
        op, data = inp
        data = int(data)
    else: op, data = inp[0], None
    if op == 'insert':
        ddl.appendleft(data,)
    elif op == 'delete':
        try:
            ddl.remove(data)
        except ValueError:
            pass
    elif op == 'deleteFirst':
        ddl.popleft()
    elif op == 'deleteLast':
        ddl.pop() i stdin inp = i.split() inp i.split() i.split i split if len(inp) == 2:
        op, data = inp
        data = int(data)
    else: op, data = inp[0], None
     len(inp) == 2 len(inp) len inp 2 op, data = inp op inp data data = int(data) data int(data) int data if op == 'insert':
        ddl.appendleft(data,)
    elif op == 'delete':
        try:
            ddl.remove(data)
        except ValueError:
            pass
    elif op == 'deleteFirst':
        ddl.popleft()
    elif op == 'deleteLast':
        ddl.pop() op == 'insert' op 'insert' ddl.appendleft(data,) ddl.appendleft ddl appendleft data elif op == 'delete':
        try:
            ddl.remove(data)
        except ValueError:
            pass
     op == 'delete' op 'delete' try:
            ddl.remove(data)
        except ValueError:
            pass
     except ValueError:
            pass
     ddl.remove(data) ddl.remove ddl remove data elif op == 'deleteFirst':
        ddl.popleft()
     op == 'deleteFirst' op 'deleteFirst' ddl.popleft() ddl.popleft ddl popleft elif op == 'deleteLast':
        ddl.pop() op == 'deleteLast' op 'deleteLast' ddl.pop() ddl.pop ddl pop str(item) for item in ddl for item in ddl item ddl for item in ddl str(item) str item print(' '.join([str(item) for item in ddl])) print ' '.join([str(item) for item in ddl]) ' '.join ' ' join [str(item) for item in ddl] inp = i.split() i.split() inp data = inp inp data data = int(data) int(data) data op, data = inp inp op n = int(input()) int(input()) n ddl = deque() deque() ddl
from collections import deque
from sys import stdin
n = int(input())
ddl = deque()
for i in stdin:
    inp = i.split()
    if len(inp) == 2:
        op, data = inp
        data = int(data)
    else: op, data = inp[0], None
    if op == 'insert':
        ddl.appendleft(data,)
    elif op == 'delete':
        try:
            ddl.remove(data)
        except ValueError:
            pass
    elif op == 'deleteFirst':
        ddl.popleft()
    elif op == 'deleteLast':
        ddl.pop()

print(' '.join([str(item) for item in ddl]))