// editor1
#include<stdio.h>
#include<string.h>
#define MAX 100
int stack [MAX];
int top = -1;
void push(int x){
    if (top == MAX -1)
    return;
    stack[++top]= x;
}
void pop(){
    if(top==-1)
    return;
    top--;
}
void peek(int x){
if (top == -1) {
    printf("Stack is empty\n");
}    else{
    printf("%d\n", stack[top]);
}
}
void display(){
    if(top== -1){
        printf("Stack is empty\n");
        return;
    }
    for(int i=0;i<=top;i++){
        printf("%d",stack[i]);
        
    }
    printf("\n");
}
int main(){
    int q,x;
    scanf("%d",&q);
    while(q--){
        char cmd[20];
        scanf("%s",cmd);

        
    
 if(strcmp(cmd,"PUSH")==0){
     scanf("%d",&x);
    push(x);
}

else if(strcmp(cmd,"POP")==0){
    pop();
}
else if(strmp(cmd,"PEEK")==0){
    peek();
}
    else if(strcmp(cmd,"DISPLAY")==0){
    display();
    
}
}
return 0;
}