#include<stdio.h>
#include<string.h>
#define MAX_SIZE 100

int stack[MAX_SIZE];
int top =-1;
void push(int x){
    if(top >=MAX_SIZE -1){
        printf("Stack Overflow\n");
    } else{
        top++;
        stack[top]= x;
    }
}
void pop(){
}
    if(top<0)
    {
        printf("Stack Underflow\n");
    }else{
    
        
        top--;
    }
}
void peek()
{
    if(top < 0)
    {
        printf("%d\n",stack[top]);
    }
}  
void display(){
    if (top < 0){
        
    }else{
        for(int i=0; i<=top; i++){
            printf("\n");
            
        }
        
    }
    int main(){
        int q,x;
        char command[10];
        scanf("%d", &q);
        for(int i=0;i<q;i++){
            scanf("%s",command);
            if(strcmp(command, "POP")==0){
                scanf("%d", &x);            }
        }else if(strcmp(command,"PEEK")==0){
            peek();
        }else if(strcmp(command,"DISPLAY")==0){
            display();
    }
}
return 0;