// editor1
#include<stdio.h>
#include<string.h>
#define max 100
int top=0;
int stack[max];
void push(int n)
{
    if(top-1==max)
    {
        printf("Stack Overflow");
        return;
    }
    stack[top++]=n;
}
void pop()
{
    if(top<0)
    {
        printf("Stack Underflow");
        return;
    }
    int val=stack[top--];
}
void disp()
{
    for(int i=0;i<top;i++)
    {
        printf("%d ",stack[i]);
    }
}

int main()
{
    int n,x;
    char operation[10];
    scanf("%d",&n);
    if(n<0)
    {
        printf("Invalid input");
        return 0;
    }
    for(int i=0;i<n;i++)
    {
    scanf("%s%d",operation,x);
    if(!strcmp("PUSH",operation))
    {
        push(x);
    }
    if(!strcmp("POP",operation))
    {
        pop();
    }
    if(!strcmp("DISPLAY",operation))
    {
        disp();
    }
    if(!strcmp("PEEK",operation))
    {
        printf("%d ",stack[top]);
    }
    else
    {
        printf("Invalid input");
        return 0;
    }
    
    
    
    }
}