#include <stdio.h>
#include<string.h>
#define max 100
int stack[max];
int top=-1;
void push(intx){
    if(top==size-1){
        printf("stack is overflow");
    }
    stack[++top]=x;
}
void pop(){
    if(top==-1){
        printf("stack underflow");
        return ;
    }
    top--;
}
void display(){
    if(top==-1){
        printf("stack underflow");
    }
    for(int i=0;i<=top;i++){
        printf("%d",stack[i]);
    }
}
void peek(){
    if(top==-1){
        printf("stack underflow");
    }
    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){
        int x;
        scanf("%d",&x);
          puch(x);
    }
   
    else if(strcmp(str,"POP")==0){
        pop();
    }else if(strcmp(str,"PEEK")==0){
        peek();
    }else if (strcmp(str,"DISPLAY")==0){
        display();
    }
    else{
        printf("Invalid input");
    }
}
return 0;
}