// editor2
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#define MAX 100
int main()
{
    int t;
    if(scanf(“%d”,&t)!=1)
    {
        printf(“Invalid input\n”);
        return 0;
    }
    if(t<1||t>100000)
    {
    printf(“Invalid input”);
    return 0 ;
    }
    int stack[MAX];
    int top=-1;
    char command[20];
    for(int I = 0;i<0;i++)
    {
        scanf(“%s”,command);
        if(strcmp(command,”push”)==0)
        {
            int x;
            scanf(“%d”,&x);
            if (top==MAX-1)
            {
                continue;
            }
            stack[++top]=x;
        }
        else if(strcmp(command,”pop”)==0)
        {
            if(top==-1)
            {
                printf(“Stack is empty\n”);
            }
        else
        {
            printf(%d\n”,stack[top--]);
        }     
    }
    else if(strcmp(command,”display”)==0)
    {
        if(top==-1)
        {
            printf(“Stack is empty\n”);
        }
        else
        {
            for(int j=top;j>=0;j--)
            { 
                printf("%d",stack[j]);
                if(j>0)printf(" ");
                {
                    printf("\n");
                }
            }
        }
    else
    {
        printf("Invalid input\n");
        return 0;
    }
        
    return 0;
}