#include <stdio.h>
#include <string.h>
int stack[201]={};
int top=-1;
void push(int a)
{
top++;
stack[top]=a;
}
void pop()
{
if(top==-1)
{
return ;
}
top--;
}
int main()
{
char str[201]={};
int a,i,num=0;
scanf("%d\n",&a);
for(i=1;i<=a;i++)
{
if(str[0]=='p' && str[1]=='u')
{
push();
}
else if(str[0]=='t')
{
if(top==-1)
{
printf("-1\n");
}
else
{
printf("%d\n",stack[top]);
}
}
else if(str[0]=='p' && str[1]=='o')
{
pop();
}
else if(str[0]=='s')
{
printf("%d\n",top);
}
else if(str[0]=='e')
{
if(top==-1)
{
printf("true\n");
}
else
{
printf("false\n");
}
}
}
return 0;
}