#include <stdio.h>
#include <stdlib.h>
#define MAX_SIZE 100
int stack[MAX_SIZE];
int top=-1;
void push(int x, int y)
{
if (top < MAX_SIZE - 2)
{
stack[++top] = x;
stack[++top] = y;
printf("Pushed\n");
} else {
printf("Overflow\n");
}
}
void pop() {
if (top < 1) {
printf("Underflow\n");
} else {
int x = stack[top--];
int y = stack[top--];
if (top < MAX_SIZE - 1) {
stack[++top] = y;
}
}
}
void top_element()
{
if (top== -1) {
printf("Empty\n");
} else {
printf("%d\n", stack[top]);
}
}
int main() {
stack;
top = -1;
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
int command;
scanf("%d", &command);
if (command == 1) {
int x, y;
scanf("%d %d", &x, &y);
push( x, y);
} else if (command == 2) {
pop();
} else if (command == 3) {
top_element();
}
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCiNkZWZpbmUgTUFYX1NJWkUgMTAwCgoKICAgIGludCBzdGFja1tNQVhfU0laRV07CiAgICBpbnQgdG9wPS0xOwoKdm9pZCBwdXNoKGludCB4LCBpbnQgeSkKIHsKICAgIGlmICh0b3AgPCBNQVhfU0laRSAtIDIpCiB7CiAgICAgICAgc3RhY2tbKyt0b3BdID0geDsKICAgICAgICBzdGFja1srK3RvcF0gPSB5OwogICAgICAgIHByaW50ZigiUHVzaGVkXG4iKTsKICAgIH0gZWxzZSB7CiAgICAgICAgcHJpbnRmKCJPdmVyZmxvd1xuIik7CiAgICB9Cn0KCnZvaWQgcG9wKCkgewogICAgaWYgKHRvcCA8IDEpIHsKICAgICAgICBwcmludGYoIlVuZGVyZmxvd1xuIik7CiAgICB9IGVsc2UgewogICAgICAgIGludCB4ID0gc3RhY2tbdG9wLS1dOwogICAgICAgIGludCB5ID0gc3RhY2tbdG9wLS1dOwogICAgICAgIGlmICh0b3AgPCBNQVhfU0laRSAtIDEpIHsKICAgICAgICAgICAgc3RhY2tbKyt0b3BdID0geTsKICAgICAgICB9CiAgICB9Cn0KCnZvaWQgdG9wX2VsZW1lbnQoKQp7CiAgICBpZiAodG9wPT0gLTEpIHsKICAgICAgICBwcmludGYoIkVtcHR5XG4iKTsKICAgIH0gZWxzZSB7CiAgICAgICAgcHJpbnRmKCIlZFxuIiwgc3RhY2tbdG9wXSk7CiAgICB9Cn0KCmludCBtYWluKCkgewogICBzdGFjazsKICAgIHRvcCA9IC0xOwoKICAgIGludCBuOwogICAgc2NhbmYoIiVkIiwgJm4pOwoKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgaW50IGNvbW1hbmQ7CiAgICAgICAgc2NhbmYoIiVkIiwgJmNvbW1hbmQpOwoKICAgICAgICBpZiAoY29tbWFuZCA9PSAxKSB7CiAgICAgICAgICAgIGludCB4LCB5OwogICAgICAgICAgICBzY2FuZigiJWQgJWQiLCAmeCwgJnkpOwogICAgICAgICAgICBwdXNoKCB4LCB5KTsKICAgICAgICB9IGVsc2UgaWYgKGNvbW1hbmQgPT0gMikgewogICAgICAgICAgICBwb3AoKTsKICAgICAgICB9IGVsc2UgaWYgKGNvbW1hbmQgPT0gMykgewogICAgICAgICAgICB0b3BfZWxlbWVudCgpOwogICAgICAgIH0KICAgIH0KCiAgICByZXR1cm4gMDsKfQ==