
python
import sys
n = int(input())
stack = []
def s_push(x: int):
stack.append(int(x))
def s_pop():
if len(stack) == 0:
return -1
return stack.pop()
def s_size():
return len(stack)
def s_empty():
if len(stack) == 0:
return 1
else:
return 0
def s_top():
if len(stack) == 0:
return -1
return stack[-1]
for i in range(n):
command = sys.stdin.readline().split()
if command[0] == "push":
s_push(command[1])
elif command[0] == "pop":
print(s_pop())
elif command[0] == "size":
print(s_size())
elif command[0] == "empty":
print(s_empty())
elif command[0] == "top":
print(s_top())