from collections import deque
n = int(input())

que = deque()
for _ in range(n):
    cmd = input()

    if cmd == 'deleteFirst':
        try:
            que.popleft()
        except:
            pass
    elif cmd == 'deleteLast':
        try:
            que.pop()
        except:
            pass
    else:
        cmd, x = cmd.split()
        if cmd == 'insert':
            que.appendleft(x)
        elif cmd == 'delete':
            try:
                que.remove(x)
            except:
                pass

print(*que) from collections import deque n = int(input()) n int(input()) int input() input que = deque() que deque() deque for _ in range(n):
    cmd = input()

    if cmd == 'deleteFirst':
        try:
            que.popleft()
        except:
            pass
    elif cmd == 'deleteLast':
        try:
            que.pop()
        except:
            pass
    else:
        cmd, x = cmd.split()
        if cmd == 'insert':
            que.appendleft(x)
        elif cmd == 'delete':
            try:
                que.remove(x)
            except:
                pass _ range(n) range n cmd = input() cmd input() input if cmd == 'deleteFirst':
        try:
            que.popleft()
        except:
            pass
    elif cmd == 'deleteLast':
        try:
            que.pop()
        except:
            pass
    else:
        cmd, x = cmd.split()
        if cmd == 'insert':
            que.appendleft(x)
        elif cmd == 'delete':
            try:
                que.remove(x)
            except:
                pass cmd == 'deleteFirst' cmd 'deleteFirst' try:
            que.popleft()
        except:
            pass
     except:
            pass
     que.popleft() que.popleft que popleft elif cmd == 'deleteLast':
        try:
            que.pop()
        except:
            pass
     cmd == 'deleteLast' cmd 'deleteLast' try:
            que.pop()
        except:
            pass
     except:
            pass
     que.pop() que.pop que pop cmd, x = cmd.split() cmd cmd.split() cmd.split cmd split x if cmd == 'insert':
            que.appendleft(x)
        elif cmd == 'delete':
            try:
                que.remove(x)
            except:
                pass cmd == 'insert' cmd 'insert' que.appendleft(x) que.appendleft que appendleft x elif cmd == 'delete':
            try:
                que.remove(x)
            except:
                pass cmd == 'delete' cmd 'delete' try:
                que.remove(x)
            except:
                pass except:
                pass que.remove(x) que.remove que remove x print(*que) print *que que cmd = input() input() cmd n = int(input()) int(input()) n que = deque() deque() que x = cmd.split() cmd.split() x cmd, x = cmd.split() cmd.split() cmd
from collections import deque
n = int(input())

que = deque()
for _ in range(n):
    cmd = input()

    if cmd == 'deleteFirst':
        try:
            que.popleft()
        except:
            pass
    elif cmd == 'deleteLast':
        try:
            que.pop()
        except:
            pass
    else:
        cmd, x = cmd.split()
        if cmd == 'insert':
            que.appendleft(x)
        elif cmd == 'delete':
            try:
                que.remove(x)
            except:
                pass

print(*que)
