#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 100
int stack[MAX];
int top=-1;
void push(int x){
    if(top==MAX-1){
        printf("Stack Overflow\n");
        return;
    }
    stack[++top]=x;
}
void pop(int x){
    if(top==-1){
        printf("Stack Unerflow\n");
        return;
    }
    top--;
}
void peek(){
    if(top==-1){
        printf("Stack Undrflow\n");
        return;
    }
    printf("%d\n",stack[top]);
}
void display(){
    if(top==-1){
        printf("Stack is empty\n");
        return;
    }
    for(int i=0;i<=top;i++){
        printf("%d",stack[i]);
    }
    printf("\n");
}
int main(){
    int q;
    if(scanf("%d",&q)!=1||q<0){
        printf("Invalid input\n");
        return 0;
    }
    char command[20];
    int value;
    getchar();
    for(int i=0;i<q;i++){
        fgets(command,sizeof(command),stdin);
        command[strcspn(command,"\n")]=0;
        if(strcmp(command,"PUSH",5)==0){
            value=atoi(command+5);
            push(value);
        }
        else if(strcmp(command,"POP")==0){
            pop();
        }
        else if(strcmp(command,"PEEK")==0){
            peek();
        }
        else if(strcmp(command,"DISPLAy")==0){
            display();
        }
        else{
            printf("Invalid command\n");
        }
    }
    return 0;
}