# class a:
# def init(self, n, d):
# self.n = n
# self.d = d
#
# def f(self):
# k = n % 3
# for i in range(k):
# print(d[i], end='')
# if k != 0 and n > 3:
# print(',', end='')
# for i in range(k, n, 1):
# if i % 3 == k and i != k:
# print(',', end='')
# print(d[i], end='')
#
#
# n = int(input())
# d = list(map(int, input()))
# x = a(n, d)
# x.f()
# class stackf:
# def init(self, count):
# self.top = 0
# self.stack = [0] * count
#
# def push(self, k):
# if self.is_full_check():
# print('Stack is Full')
# return
# if self.is_numberic(k):
# print('Value is not a number')
# return
# self.stack[self.top] = k
#
# def pop(self):
# if self.is_empty_check():
# print('Stack is Empty')
# return
# return self.stack[self.top]
#
# def is_full_check(self):
# if self.top == 5:
# return 1
# else:
# return 0
#
# def is_empty_check(self):
# if self.top == 0:
# return 1
# else:
# return 0
#
# def view(self):
# for i in range(self.top):
# print(self.stack[i], end=' ')
# print()
#
# def is_numberic(self, k):
# if :
# return 0
# else:
# return 1
#
#
# s = stackf(5)
#
# while True:
# x = int(input('1: InputData\n2: OutputData\n3: View int Stack\ninput:'))
# if x == 1:
# k = input('Input Value:')
# s.push(k)
# if x == 2:
# s.pop()
# if x == 3:
# s.view()
# class stackf:
# def init(self, count):
# self.top = 0
# self.stack = [0] * count
#
# def push(self, k):
# if self.is_full_check():
# return
# if self.is_numberic(k):
# return
# self.stack[self.top] = k
#
# def pop(self):
# if self.is_empty_check():
# return
# return self.stack[self.top]
#
# def is_full_check(self):
# if self.top == 100001:
# return 1
# else:
# return 0
#
# def is_empty_check(self):
# if self.top == 0:
# return 1
# else:
# return 0
#
# def view(self):
# for i in range(self.top):
# print(self.stack[i], end=' ')
# print()
#
# def is_numberic(self, k):
# if k:
# return 0
# else:
# return 1
#
# def t(self):
# return self.top
#
#
# k = int(input())
# s = stackf(k)
# for i in range(k):
# a = int(input())
# if a == 0:
# s.pop()
# else:
# s.push(a)
# sum = 0
# p = s.t()
# for i in range(p):
# sum = sum + s.stack[i]
# print(sum)
# d = list(input().split())
# re = [0] * (len(d) + 200)
# q = 0
#
# class stackf:
# def init(self, count):
# self.top = 0
# self.stack = [] * count
#
# def push(self, k):
# # if self.is_full_check():
# # return
# # if self.is_numberic(k):
# # return
# self.stack.append(k)
#
# def pop(self):
# if self.is_empty_check():
# return
# return self.stack[self.top]
#
# def is_full_check(self):
# if self.top == 100000:
# return 1
# else:
# return 0
#
# def is_empty_check(self):
# if self.top == 0:
# return 1
# else:
# return 0
#
# def view(self):
# for i in range(self.top):
# print(self.stack[i], end=' ')
# print()
#
# def is_numberic(self, k):
# if k:
# return 0
# else:
# return 1
#
# def t(self):
# return self.top
#
#
# def c(x):
# if x == '*':
# return m1()
# if x == '+':
# return pl1()
# if x == '-':
# return mi1()
# return x
#
#
# def m():
# global q
# global s
# global re
# b = s.pop()
# b = c(b)
# a = s.pop()
# a = c(a)
# re[q] = b
# q = q + 1
# re[q] = '*'
# q = q + 1
# re[q] = a
# q = q + 1
# return a + ' * ' + b
#
#
# def pl():
# global q
# global s
# global re
# b = s.pop()
# b = c(b)
# a = s.pop()
# a = c(a)
# re[q] = b
# q = q + 1
# re[q] = '+'
# q = q + 1
# re[q] = a
# q = q + 1
# return a + ' + ' + b
#
#
# def mi():
# global q
# global s
# global re
# b = s.pop()
# b = c(b)
# a = s.pop()
# a = c(a)
# re[q] = b
# q = q + 1
# re[q] = '-'
# q = q + 1
# re[q] = a
# q = q + 1
# return a + ' - ' + b
#
#
# def m1():
# global q
# global s
# global re
# b = s.pop()
# b = c(b)
# a = s.pop()
# a = c(a)
# return a + ' * ' + b
#
#
# def pl1():
# global q
# global s
# global re
# b = s.pop()
# b = c(b)
# a = s.pop()
# a = c(a)
# return a + ' + ' + b
#
#
# def mi1():
# global q
# global s
# global re
# b = s.pop()
# b = c(b)
# a = s.pop()
# a = c(a)
# return a + ' - ' + b
#
#
# s = stackf(len(d))
#
# for i in range(len(d)):
# s.push(d[i])
# p = s.t()
# while p != 0:
# x = s.pop()
# if x == '*':
# m()
# elif x == '+':
# pl()
# elif x == '-':
# mi()
# p = s.t()
#
#
# for i in range(q-1, -1, -1):
# print(re[i], end=' ')
# data = input().split()
# print(data)
#
# number = []
# oper = []
#
# for i in range(len(data)):
# print('xx>', data[i])
# if data[i] == '+' or data[i] == '-' or data[i] == '*':
# oper.append(data[i])
# x = oper.pop(0)
# n2 = number.pop()
# n1 = number.pop()
# p = n1 + x + n2
# number.append(p)
# else:
# number.append(data[i])
#
#
# print(number[0])
# class stackf:
# def init(self, count):
# self.top = 0
# self.stack = [] * count
#
# def push(self, k):
# # if self.is_full_check():
# # return
# # if self.is_numberic(k):
# # return
# self.stack.append(k)
#
# def pop(self):
# if self.is_empty_check():
# return
# return self.stack[self.top]
#
# def is_full_check(self):
# if self.top == 100000:
# return 1
# else:
# return 0
#
# def is_empty_check(self):
# if self.top == 0:
# return 1
# else:
# return 0
#
# def view(self):
# for i in range(self.top):
# print(self.stack[i], end=' ')
# print()
#
# def is_numberic(self, k):
# if k:
# return 0
# else:
# return 1
#
# def t(self):
# return self.top
#
#
# def m():
# global s
# b = s.pop()
# b = c(b)
# a = s.pop()
# a = c(a)
# return int(a) * int(b)
#
#
# def pl():
# global s
# b = s.pop()
# b = c(b)
# a = s.pop()
# a = c(a)
# return int(a) + int(b)
#
#
# def mi():
# global s
# b = s.pop()
# b = c(b)
# a = s.pop()
# a = c(a)
# return int(a) - int(b)
#
#
# def c(x):
# if x == '*':
# return m()
# if x == '+':
# return pl()
# if x == '-':
# return mi()
# return x
#
#
# d = list(input().split())
# s = stackf(len(d))
# for i in range(len(d)):
# s.push(d[i])
# for i in range(len(d)):
# x = s.pop()
# if x == '*':
# r = m()
# elif x == '+':
# r = pl()
# elif x == '-':
# r= mi()
#
# print(r)
class stackf:
def init(self, count):
self.top = 0
self.stack = []
def push(self, k):
self.stack.append(k)
def pop(self):
if self.is_empty_check1():
return -1
return self.stack[self.top]
def is_full_check(self):
if self.top == 100000:
return 1
else:
return 0
def is_empty_check(self):
if self.top == 0:
return 'true'
else:
return 'false'
def is_empty_check1(self):
if self.top == 0:
return 1
else:
return 0
def view(self):
for i in range(self.top):
print(self.stack[i])
print()
def is_numberic(self, k):
if k:
return 0
else:
return 1
def t(self):
return self.top
def top1(self):
return self.stack[self.top-1]
n = int(input())
x = stackf(n)
for i in range(n):
d = list(input())
if d[0] == 'p':
if d[1] == 'u':
x.push(d[6])
else:
x.pop()
elif d[0] == 't':
print(x.top1())
elif d[0] == 's':
print(x.t())
else:
print(x.is_empty_check())