https://www.acmicpc.net/problem/10845
import sys
que = []
count = int(input())
n = 0
while n < count:
n += 1
line = sys.stdin.readline().strip()
if "push" in line:
que.append(int(line.split()[1]))
elif "pop" in line:
if que:
print(que.pop(0))
else:
print('-1')
elif "front" in line:
if que:
print(que[0])
else:
print('-1')
elif "back" in line:
if que:
print(que[-1])
else:
print('-1')
elif "size" in line:
print(len(que))
elif "empty" in line:
if que:
print('0')
else:
print('1')