#include<stdio.h>
#include<string.h>

int stack[100], top=-1;

int main(){
    int d;
    if(scanf("%d",&q) !=1 || q<0)
    {
        printf("Invalid input\n");
        return 0;
    }
    while(q--){
        cahr cmd[10];
        scanf("%s", cmd);
        if(strcmd(cmd."PUSH")==0){
            int x; scanf("%d", &x);
            stack[++top]=x;
            
        }
        else if(cmp,"POP")==0)
        {
            if(top==-1)
            printf("Stack Underflow\n");
            else top--;
        }
      else if(cmp,"PEEK")==0)
        {
            if(top==-1)
            printf("Stack Underflow\n");
            else 
            printf("%d\n", stack[top]);
    }
    else if(strcmp(cmd,"DISPLAY")==0)
    {
        for(int i=0;i<=top;i++)
        printf("%d %s",stack[i],i==top?"\n":" ");
    }
    
    }
   
}