#include <stdio.h>
#include<string.h>
int main()
{
int n;
scanf("%d",&n);
long long int a[n];
char s[10];
int j=0,flag=0;
for(int i=0;i<n;i++)
{
scanf("%s",s);
if(strcmp(s,"push")==0)
{
scanf("%lld",&a[j]);
j++;
}
else if(strcmp(s,"pop")==0)
{
if(j==0)
{
printf("Empty\n");
continue;
}
else
{
j--;
}
}
else if(strcmp(s,"query")==0)
{
if(j==0)
{
printf("Empty\n");
continue;
}
else
{
printf("%lld\n",a[j-1]);
}
}
else
{
printf("%d\n",j);
}
}
return 0;
}

京公网安备 11010502036488号