#include<stdio.h>
#include<string.h>
int main() {
    int q, top=-1;
    int stack[100];
    scanf("%d", &q);
    if(q<0){
        printf("Invalid input");
        return 0;
    }
    while(q--){
        char cmd[10];
        scanf("%s", cmd);
        if(strcmp(cmd, "PUSH")==0){
            int x;
            scanf("%d", &x;
            stack[++top]=x;
            }
            else if (strcmp(cmd, "POP")==0){
                if(top==-1)
                printf("Stack Unnderflow\n");
                else
                top--;
            }
            else if (strcmp(cmd, "PEEK")==0){
                if(top==-1)
                printf("Stack Underflow\n");
                else
                printf("%d\n", stack[top]);
            }
            else if(strcmp(cmd, "DISPLAY")==0){
                if(top==-1)
                printf("Stack Undewrflow\n");
                else
                for(int i=0;i<=top;i++)
                printf("%d ",stack[i]);
                printf("\n");
            }
    }
    return 0;
}