#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top=-1,size=5;
int arr[100];
int isfull()
{
    if(top==size-1)
        return 1;
    else
     return 0;

}
void push(int num)
{
    if(isfull())
      printf("Stack is full");
    else
    arr[++top]=num;
}
int isempty()
{
    if(top==-1)
      return -1;
    else
      return 0;
}
void pop()
{
    if(isempty())
    printf("Stack Underflow");
    else
     top--;
}
int peek()
{
    if(isempty())
    return -1;
    else
       return arr[top];
}
void display()
{
    if(isempty())
    {
        printf("empty\n");
    }
    for(int i=0;i<=top;i++)
    {
        printf("%d",arr[i]);
        printf("\n");
    }
}
int main()
{
    int q,num;
    char cmd[20];
    scanf("%d",&q);
    while(q--)
    {
     scanf("%s",cmd);
    if(strcmp(cmd,"PUSH")==0)
    {
         scanf("%d",&num);
         push(num);
    }
    else if(strcmp(cmd,"POP")==0)
    {
    pop();
    }
    else if(strcmp(cmd,"PEEK")==0)
    {
    int ans=peek();
    if(ans==-1)
    {
        printf("stack is empty");
        
    }
    else
    {
        printf("%d",ans);
    }
    else if(strcmp(cmd,"DISPLAY")==0)
    {
        display();
    }
}