#include<stdio.h>
#include<stdlib.h>
#define max 5
int stack[100];
int top = -1;

void push(int value){
    if(top == max-1){
        printf("Invalid input");
    }
    else{
        stack[++top] = value;
        printf("%d ",value);
    }
}

void pop(){
    if(top == -1){
        printf("Invalid input \n");
    }
    else{
        Printf("POP");
        stack[top--];
        printf("\n");
    }
}

void peek(){
    if(top == -1){
        printf("Invalid input");
    }
    else{
        printf("PEEK");    
        printf("%d\n",stack[top]);
    }
}

void display(){
    if(top==-1){
        printf("Invalid input");
        return 0;
    }
    else{
        printf("DISPLAY");
        for(int i=0;i<=top;i++){
            printf("%d",stack[i]);
        }
        printf("\n");
    }
} 


int main(){
    int choice, value;

    while(1){
        
        switch(choice){
            scanf("%d",&choice);    
       
            case 1:
            scanf("%d",&value);
            push(value);
            break;
            
            case 2:
            pop();
            break;
            
            case 3:
            display();
            break;
            
            case 4:
            peek();
            break;
            
            case 5:
            exit(0);
            
            default:
            printf("Invalid input");
        }
    }
    return 0;
}