/*
#include<stdio.h>
int main()
{
int stack[200],top=-1,n;
char str[201]={};
scanf("%d %s",&n,str);
for(int i=n-1;i>=0;i--)
{
top++;
stack[top]=str[i]-'0';
}
while(top!=-1)
{
if(top!=0&&top%3==2&&top!=n-1)
{
printf(",");
}
printf("%d",stack[top--]);
}
}
*/
/*#include<stdio.h>
int main()
{
int a=0,i,stack[100000],top=-1,k;
int input;
scanf("%d",&k);
for(i=0; i<k; i++)
{
scanf("%d",&input);
if(input==0)
{
top--; //pop
}
else
{
stack[++top]=input; //push
}
}
while(top!=-1)
{
a+=stack[top];
top--;
}
printf("%d",a);
}*/
/*#include<stdio.h>
int main()
{
int top=0,sta=0;
char stack[50000];
scanf("%s",stack);
while(stack[top]!=NULL)
{
if(stack[top]=='(')
{
sta++;
}
else if(stack[top]==')'&&sta>0)
{
sta--;
}
else
{
sta=-100;
}
top++;
}
if(sta==0)
{
printf("good");
}
else
{
printf("bad");
}
}*/
#include<stdio.h>
int top=-1;
char stack[200];
void pu(int x)
{
stack[++top]=x-'0';
}
void po()
{
top--;
}
void to()
{
printf("%d",stack[top]);
}
void si()
{
printf("%d",top);
}
void em()
{
if(top==-1)
{
printf("true");
}
else
{
printf("false");
}
}
int main()
{
int n,i,x;
char a[10];
scanf("%d ",&n);
for(i=0;i<n;i++)
{
scanf("%s",a);
if(a[1]=='u')
{
scanf("%d %s\n",&x,a);
pu(x);
}
else
{
switch(stack[0])
{
case't':to();break;
case'p':po();break;
case's':si();break;
case'e':em();break;
}
}
}
}