#include<stdio.h>
#include<string.h>
#define MAX 100
int main()
{
    int stack[MAX];
    int top=-1,q,x;
    char command[10];
    scanf("%d",&q);
    if(q<0)
    {
        printf("Invalid input");
        return 0;
    }
    for(int i=0;i<q;i++)
    {
        scanf("%s",command);
        
    if(strcmp(command,"PUSH")==0)
    {
        scanf("%d",&x);
    }
    if(top==MAX-1)
    {
        printf("StackOverflow");
    }
    else
    {
        stack[++top]=x;
    }
    }
    
    else if(strcmp(command,"POP")==0)
    {
        if(top==-1)
        {
            printf("Stack Underflow\n");
        }
        else
        {
            top--;
        }
    }
    else if(strcmp(command,"PEEK")==0)
    {
        if(top==-1)
        {
         printf("Stack Underflow");   
        }
        else
        {
            printf("%d ",stack[top]);
        }
    }
    else if(strcmp(command,"DISPLAY")==0)
    {
        if(top==-1)
        {
            printf("Stack Underflow");
        }
        else
        {
            for(int j=0;j<=top;j++)
            {
                printf("%d",stack[i]);
            }
            printf("\n");
        }
    }
    else
    {
        printf("Invalid input");
    }
}
return 0;
}