문제 확인하기
from collections import deque
N = int(input())
deq = deque()
for _ in range(N):
command = list(map(str, input().split()))
if command[0] == "append":
deq.append(int(command[1]))
elif command[0] == "appendleft":
deq.appendleft(int(command[1]))
elif command[0] == "clear":
deq.clear()
elif command[0] == "extend":
deq.extend(command[1])
elif command[0] == "extendleft":
deq.extendleft(command[1])
elif command[0] == "count":
deq.count(command[1])
elif command[0] == "pop":
deq.pop()
elif command[0] == "popleft":
deq.popleft()
elif command[0] == "remove":
deq.remove(command[1])
elif command[0] == "reverse":
deq.reverse()
elif command[0] == "rotate":
deq.rotate(int(command[1]))
print(*list(deq))