#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 100
int stack[MAX];
int top= -1;
void push(int val)
{
    if(top<MAX - 1)
    {
        stack[++top]=val;
    }
}
void pop()
{
    if(top >=0)
    {
        return stack[top];
    }
    return -1;
}
void display()
{
    for(int i=0;i<=top;i++)
    {
        printf("%d",stack[i]);
    }
    printf("\n");
}
int main()
char input[500];
char *token=strtok(input,",");
int q=atoi(token);
for(int i=0;i<q;i++)
{
    token=strtok(NULL,",");
    if(strcmp(token,"push",4)==0)
    {
        int val=atoi(token + 5);
        push(val);
    }
    else if(strcmp(token,"pop")==0)
    {
        pop();
    }
    else if(strcmp(token,"peek")==0)
    {
        printf("%d\n",peek());
    }
    else if(strcmp(token,"display")==0)
    {
        display();
    }
}
return 0;