// editor1
#include<stdio.h>
#include<string.h>
#define max 100
int stack[max];

void push(int x){
   if(top==max-1){
       printf("stack overflow");
   } 
   stack[++top]=x;
}
void pop(){
    if(top==-1){
        printf("stack underflow");
        return;
    }
    top--;
}
void peek(){
    if(top==-1){
        printf("stack is emp");
    }
}
void display(){
    if(top=-1){
        printf("stack underflow");
    }
    for(int t=0;i<=top;i++){
        printf("%d",stack[i]);
    }
}
int main(){
    int size;
    scanf("%d",&size);
    char str[20];
    for(int i=0;i<size;i++){
        scanf("%s",&str);
        if(strcmp(str="PUSH")==0)
         
          push();
        else if(strcmp(str="POP")==0)
          pop();
        else if(strcmp(str="PEEK")==0)
          peek();
        else if(strcmp(str="DISPLAY")==0)
          display();
    }
    return 0;
}