Buggy python submission (verdict: Runtime Error):
from collections import deque

n = int(input())
que = deque()

for i in range(n):
    command = input()
    if command == "deleteFirst":
        que.popleft()
    elif command == "deleteLast":
        que.pop()
    else:
        a, b = command.split()
        if a == "insert":
            que.appendleft(b)
        else:
            que.remove(b)

print(*que)

Fixed submission:
import sys
from collections import deque

n = int(input())
que = deque()

for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == "i":
        que.appendleft(command[7:])
    elif command[6] == " ":
        try:
            que.remove(command[7:])
        except:
            pass
    elif command[6] == "F":
        que.popleft()
    else:
        que.pop()
print(*que)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

n = int(input())
que = deque()

for i in range(n):
    command = input()
    if command == "deleteFirst":
        que.popleft()
    elif command == "deleteLast":
        que.pop()
    else:
        a, b = command.split()
        if a == "insert":
            que.appendleft(b)
        else:
            try:
                que.remove(b)
            except:
                pass
print(*que)

Fixed submission:
import sys
from collections import deque

n = int(input())
que = deque()

for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == "i":
        que.appendleft(command[7:])
    elif command[6] == " ":
        try:
            que.remove(command[7:])
        except:
            pass
    elif command[6] == "F":
        que.popleft()
    else:
        que.pop()
print(*que)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

n = int(input())
que = deque()

for i in range(n):
    command = input()
    if command == "deleteFirst":
        que.popleft()
    elif command == "deleteLast":
        que.pop()
    elif command[0] == "i":
        que.appendleft(command[7:])
    else:
        try:
            que.remove(command[7:])
        except:
            pass
print(*que)

Fixed submission:
import sys
from collections import deque

n = int(input())
que = deque()

for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == "i":
        que.appendleft(command[7:])
    elif command[6] == " ":
        try:
            que.remove(command[7:])
        except:
            pass
    elif command[6] == "F":
        que.popleft()
    else:
        que.pop()
print(*que)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

n = int(input())
que = deque()

for i in range(n):
    command = input()
    if command[0] == "i":
        que.appendleft(command[7:])
    elif "deleteFirst" in command:
        que.popleft()
    elif "deleteLast" in command:
        que.pop()
    else:
        try:
            que.remove(command[7:])
        except:
            pass
print(*que)

Fixed submission:
import sys
from collections import deque

n = int(input())
que = deque()

for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == "i":
        que.appendleft(command[7:])
    elif command[6] == " ":
        try:
            que.remove(command[7:])
        except:
            pass
    elif command[6] == "F":
        que.popleft()
    else:
        que.pop()
print(*que)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

n = int(input())
que = deque()

for i in range(n):
    command = input()
    if command[0] == "i":
        que.appendleft(command[7:])
    elif "deleteFirst" in command:
        que.popleft()
    elif "deleteLast" in command:
        que.pop()
    else:
        try:
            que.remove(command[7:])
        except:
            pass
print(" ".join(que))

Fixed submission:
import sys
from collections import deque

n = int(input())
que = deque()

for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == "i":
        que.appendleft(command[7:])
    elif command[6] == " ":
        try:
            que.remove(command[7:])
        except:
            pass
    elif command[6] == "F":
        que.popleft()
    else:
        que.pop()
print(*que)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

n = int(input())
que = deque()

for i in range(n):
    command = input()
    if command[0] == "i":
        que.appendleft(command[7:])
    elif command[6] == " ":
        try:
            que.remove(command[7:])
        except:
            pass
    elif command[6] == "F":
        que.popleft()
    else:
        que.pop()
print(" ".join(que))

Fixed submission:
import sys
from collections import deque

n = int(input())
que = deque()

for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == "i":
        que.appendleft(command[7:])
    elif command[6] == " ":
        try:
            que.remove(command[7:])
        except:
            pass
    elif command[6] == "F":
        que.popleft()
    else:
        que.pop()
print(*que)