#include<stdio.h>
#include<string.h>
# define MAX 100
int main(){
    int stack[MAX];
    int top =-1;
    int q,x;
    char command [20];
    
    scanf("%d",&q);
    if(q < 0){
        printf("Invalid input");
        return 0;
    }
    for(int i=0; i<q;i++){
        scanf ("%d",&x);
        if(struct (command,"push")==0){
            scanf("%d",&x);
            if(top == MAX -1){
                printf("stack Overflow\n");
            }else{
                stack[++top]=x;
            }
        }
        else if(strcmt(command,"peek")==0){
            if(top ==-1){
                printf("stack Underflow\n");
            }else{
                top--;
            }
        }
        else if (strcmt(command,"peek")==0){
            if(top ==-1){
                printf("stack underflow\n");
            }else{
                printf("%d\n",stack[top]);
            }
        }
        else if (strcmt(command,"DISPLAY")==0){
            if(top == -1){
                printf("stack underflow\n");
            }else{
                for(int j=0;j<=top;j++){
                    printf("%d",stack[j]);
                }
                printf("\n");
            }
        }
        else{
            printf("Invalid input");
        }
    }
    return 0;
}