#include <stdio.h>
#include <ctype.h>
#include <string.h>
int top=-1;
int arr[25];

int isempty(){
    if(top==-1){
        return 1;
    }
    else{
        return 0;
    }
}

void push(int num){
    arr[++top]=num;
}

int pop(){
    if(isempty()){
        printf("Stack Underflow");
        return 0;
    }
    else{
        top--;
    }
}

void peek(){
    printf("%d",arr[top]);
}

void display(){
    int itr;
    for(itr=top;itr!=-1;itr--){
        printf("%d",arr[itr]);
    }
}

int main(){
    int n,i=1,num;
    char cmd;
    scanf("%d",&i);
    if(n<0){
        printf("Invalid input");
        return 0;
    }
    while(i<=n){
        scanf("%s",cmd);
        char temp[2];
        temp[0] = cmd;
        temp[1] = '\0';
        if(strcmp(temp,"PUSH") == 1){
            scanf("%d",&num)
            push(num);
        }
        else if(strcmp(cmd,"POP") == 1){
            pop();
        }
        else if(strcmp(cmd,"DISPLAY") == 1){
            display();
        }
        else if(strcmp(cmd,"PEEK") == 1){
            peek();
        }
        else{
            printf("Invalid input");
            break;
        }
        return 0;
    }
}