import sys
def push(stack: list, x):
stack.append(x)
return stack
def pop(stack: list):
if(stack):
print(stack.pop())
else:
print("error")
return stack
def top(stack: list):
if(stack):
print(stack[-1])
else:
print("error")
return stack
if __name__ == "__main__":
stack = []
for line in sys.stdin:
if line.startswith("push "):
stack = push(stack, int(line.replace("push ", "")))
elif line.startswith("pop"):
stack = pop(stack)
elif line.startswith("top"):
stack = top(stack)



京公网安备 11010502036488号