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