#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
from collections import deque

n = int(stdin.readline())
dll = deque()
fcode = ord('F')
lcode = ord('L')
while n:
    n -= 1
    cmd = stdin.readline().rstrip()
    if cmd.startswith('i'):
        dll.appendleft(int(cmd[7:]))
    elif cmd.startswith('d'):
        c = ord(cmd[6])
        if c == fcode:
            dll.popleft()
        elif c == lcode:
            dll.pop()
        else:
            try:
                dll.remove(int(cmd[7:]))
            except ValueError:
                pass
print(*dll) from __future__ import division, print_function from sys import stdin from collections import deque n = int(stdin.readline()) n int(stdin.readline()) int stdin.readline() stdin.readline stdin readline dll = deque() dll deque() deque fcode = ord('F') fcode ord('F') ord 'F' lcode = ord('L') lcode ord('L') ord 'L' while n:
    n -= 1
    cmd = stdin.readline().rstrip()
    if cmd.startswith('i'):
        dll.appendleft(int(cmd[7:]))
    elif cmd.startswith('d'):
        c = ord(cmd[6])
        if c == fcode:
            dll.popleft()
        elif c == lcode:
            dll.pop()
        else:
            try:
                dll.remove(int(cmd[7:]))
            except ValueError:
                pass n n -= 1 n 1 cmd = stdin.readline().rstrip() cmd stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip if cmd.startswith('i'):
        dll.appendleft(int(cmd[7:]))
    elif cmd.startswith('d'):
        c = ord(cmd[6])
        if c == fcode:
            dll.popleft()
        elif c == lcode:
            dll.pop()
        else:
            try:
                dll.remove(int(cmd[7:]))
            except ValueError:
                pass cmd.startswith('i') cmd.startswith cmd startswith 'i' dll.appendleft(int(cmd[7:])) dll.appendleft dll appendleft int(cmd[7:]) int cmd[7:] cmd 7: 7 elif cmd.startswith('d'):
        c = ord(cmd[6])
        if c == fcode:
            dll.popleft()
        elif c == lcode:
            dll.pop()
        else:
            try:
                dll.remove(int(cmd[7:]))
            except ValueError:
                pass cmd.startswith('d') cmd.startswith cmd startswith 'd' c = ord(cmd[6]) c ord(cmd[6]) ord cmd[6] cmd 6 if c == fcode:
            dll.popleft()
        elif c == lcode:
            dll.pop()
        else:
            try:
                dll.remove(int(cmd[7:]))
            except ValueError:
                pass c == fcode c fcode dll.popleft() dll.popleft dll popleft elif c == lcode:
            dll.pop()
         c == lcode c lcode dll.pop() dll.pop dll pop try:
                dll.remove(int(cmd[7:]))
            except ValueError:
                pass except ValueError:
                pass dll.remove(int(cmd[7:])) dll.remove dll remove int(cmd[7:]) int cmd[7:] cmd 7: 7 print(*dll) print *dll dll n = int(stdin.readline()) int(stdin.readline()) n n -= 1 1 n lcode = ord('L') ord('L') lcode c = ord(cmd[6]) ord(cmd[6]) c dll = deque() deque() dll cmd = stdin.readline().rstrip() stdin.readline().rstrip() cmd fcode = ord('F') ord('F') fcode
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
from collections import deque

n = int(stdin.readline())
dll = deque()
fcode = ord('F')
lcode = ord('L')
while n:
    n -= 1
    cmd = stdin.readline().rstrip()
    if cmd.startswith('i'):
        dll.appendleft(int(cmd[7:]))
    elif cmd.startswith('d'):
        c = ord(cmd[6])
        if c == fcode:
            dll.popleft()
        elif c == lcode:
            dll.pop()
        else:
            try:
                dll.remove(int(cmd[7:]))
            except ValueError:
                pass
print(*dll)