from functools import reduce
from collections import deque


def operate(dq, op):
    if op[0] == 'i':
        dq.appendleft(int(op[7:]))
    else:
        k = op[6]
        if k == 'F':
            dq.popleft()
        elif k == 'L':
            dq.pop()
        else:
            try:
                dq.remove(int(op[7:]))
            except ValueError:
                pass
    return dq


n = int(input())
print(*reduce(operate, [input() for _ in range(n)], deque())) from functools import reduce from collections import deque def operate(dq, op):
    if op[0] == 'i':
        dq.appendleft(int(op[7:]))
    else:
        k = op[6]
        if k == 'F':
            dq.popleft()
        elif k == 'L':
            dq.pop()
        else:
            try:
                dq.remove(int(op[7:]))
            except ValueError:
                pass
    return dq operate if op[0] == 'i':
        dq.appendleft(int(op[7:]))
    else:
        k = op[6]
        if k == 'F':
            dq.popleft()
        elif k == 'L':
            dq.pop()
        else:
            try:
                dq.remove(int(op[7:]))
            except ValueError:
                pass
     op[0] == 'i' op[0] op 0 'i' dq.appendleft(int(op[7:])) dq.appendleft dq appendleft int(op[7:]) int op[7:] op 7: 7 k = op[6] k op[6] op 6 if k == 'F':
            dq.popleft()
        elif k == 'L':
            dq.pop()
        else:
            try:
                dq.remove(int(op[7:]))
            except ValueError:
                pass
     k == 'F' k 'F' dq.popleft() dq.popleft dq popleft elif k == 'L':
            dq.pop()
         k == 'L' k 'L' dq.pop() dq.pop dq pop try:
                dq.remove(int(op[7:]))
            except ValueError:
                pass
     except ValueError:
                pass
     dq.remove(int(op[7:])) dq.remove dq remove int(op[7:]) int op[7:] op 7: 7 return dq dq dq dq op op n = int(input()) n int(input()) int input() input input() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) input() input print(*reduce(operate, [input() for _ in range(n)], deque())) print *reduce(operate, [input() for _ in range(n)], deque()) reduce(operate, [input() for _ in range(n)], deque()) reduce operate [input() for _ in range(n)] deque() deque def operate(dq, op):
    if op[0] == 'i':
        dq.appendleft(int(op[7:]))
    else:
        k = op[6]
        if k == 'F':
            dq.popleft()
        elif k == 'L':
            dq.pop()
        else:
            try:
                dq.remove(int(op[7:]))
            except ValueError:
                pass
    return dq def operate(dq, op):
    if op[0] == 'i':
        dq.appendleft(int(op[7:]))
    else:
        k = op[6]
        if k == 'F':
            dq.popleft()
        elif k == 'L':
            dq.pop()
        else:
            try:
                dq.remove(int(op[7:]))
            except ValueError:
                pass
    return dq operate n = int(input()) int(input()) n
from functools import reduce
from collections import deque


def operate(dq, op):
    if op[0] == 'i':
        dq.appendleft(int(op[7:]))
    else:
        k = op[6]
        if k == 'F':
            dq.popleft()
        elif k == 'L':
            dq.pop()
        else:
            try:
                dq.remove(int(op[7:]))
            except ValueError:
                pass
    return dq


n = int(input())
print(*reduce(operate, [input() for _ in range(n)], deque()))