// editor1
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 100

int top=-1;
int arr[MAX];

int isFull(){
    if(top==MAX-1){
        return 1;
    }else{
        return 0;
    }
}

int isEmpty(){
    if(top==-1){
        return 1;
    }else{
        return 0;
    }
}

void push(int num){
    if(isFull()){
        printf("Stack is Full");
        return;
    }
    arr[++top]=num;
}

void pop(){
    if(isEmpty()){
        printf("Stack is Empty");
        return;
    }
    top--;
}

void peek(){
    if(isEmpty()){
        printf("Stack is Empty");
        return;
    }
    printf("%d\n",arr[top]);
}

void display(){
    if(isEmpty()){
        printf("Stack is Empty");
        return;
    }
    for(int i=0;i<=top;i++){
        printf("%d ",arr[i]);
    }
    printf("\n");
}

int main(){
    int n,num;
    scanf("%d",&n);
    if(n<=0){
        printf("Invalid input");
        return 0;
    }
    char *temp[10];
    
    for(int i=0;i<n;i++){
        scanf("%s",&temp);
        if(strcmp(temp,"PUSH")==0){
            scanf("%d",&num);
            push(num);
        }else if(strcmp(temp, "POP")==0){
            pop();
        }else if(strcmp(temp, "PEEK")==0){
            peek();
        }else if(strcmp(temp, "DISPLAY")==0){
            display();
        }else{
            printf("Invalid input\n");
            return 0;
        }
    }
    return 0;
    
}