#include <stdio.h>
#include <string.h>
#define MAX 100
int main(){
    int stack[MAX];
    int top = -1;
    int q;
    scanf("%d", &q);
    if(q < 0){
        printf("Invalid input");
        return 0;
    }
    while (q--){
        char commad[20];
        scanf("%s", command);
        if(strcmp(command, "PUSH") == 0){
            int x;
            scanf("%d", &x);
            if(top < MAX - 1){
                stack[++top] = x;
            }
        }
        else if (strcmp(command, "PEEK") == 0){
            if(top != -1){
                printf("%d\n", stack[top]);
            }
        }
        else if(strcmp(command, "DISPALY") == 0){
            if(top != -1){
                for(int i = 0; i <= top; i++){
                    printf("%d", stack[i]);
                    if(i < top)
                       pritnf(" ";)
                }
                printf("\n");
            }
        }
    }
    retrun 0 ;
}