https://www.acmicpc.net/problem/10845
class Queue:
def __init__(self):
self.queue = []
def push(self,num):
self.queue.append(num)
def pop(self):
if len(self.queue) == 0:
return -1
else:
ans = self.queue[0]
del self.queue[0]
return ans
def size(self):
return len(self.queue)
def empty(self):
if len(self.queue) == 0:
return 1
else:
return 0
def front(self):
if len(self.queue) == 0:
return -1
else:
return self.queue[0]
def back(self):
if len(self.queue) == 0:
return -1
else:
return self.queue[-1]
n=int(input())
t=Queue()
an=[]
count=0
for i in range(n):
arr = input().split()
st = arr[0]
if st == "push":
t.push(arr[1])
elif st == "pop":
an.append(t.pop())
count+=1
elif st == "size":
an.append(t.size())
count+=1
elif st == "empty":
an.append(t.empty())
count+=1
elif st == "front":
an.append(t.front())
count+=1
elif st == "back":
an.append(t.back())
count+=1
for i in range(count):
print(an[i])