#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 5

int stack[MAX];
int top = -1;

void push(int x) {
    if (top == MAX - 1) {
        printf("Stack overflow\n");
    } else {
        stack[++top] = x;
    }
}

void peek() {
    if (top == -1) {
        printf("Stack is empty\n");
    } else {
        printf("%d\n", stack[top]);
    }
}

int main() {
    int n;
    if (scanf("%d", &n) != 1 || n < 1) {
        printf("Invalid input\n");
        return 1;
    }

    char command[10];
    for (int i = 0; i < n; i++) {
        if (scanf("%s", command) != 1) {
            printf("Invalid input\n");
            return 1;
        }