from collections import deque
import sys
input=sys.stdin.readline
n=int(input())
que=deque()
def push(p):
que.append(p)
def pop():
if len(que)!=0:
print(que.popleft()) #맨 앞 pop
else:
print(-1)
def size():
print(len(que))
def empty():
if len(que)==0:
print(1)
else:
print(0)
def front():
if len(que)!=0:
print(que[0])
else:
print(-1)
def back():
if len(que)!=0:
print(que[-1])
else:
print(-1)
for i in range(n):
command=input().split()
if command[0]=='push':
push(command[1])
elif command[0]=='pop':
pop()
elif command[0]=='size':
size()
elif command[0]=='empty':
empty()
elif command[0]=='front':
front()
elif command[0]=='back':
back()
접근 방법