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