#include <stdio.h>
#include <stdlib.h>
#define MAX_SIZE 100
int stack[MAX_SIZE];
int top=-1,count=0;
int size()
{
return count;
}
void push(int x, int y)
{
if (count+2<=MAX_SIZE )
{
stack[++top] = x;
stack[++top] = y;
printf("Pushed\n");
} else {
printf("Overflow\n");
}
}
void pop() {
if (count< 2) {
printf("Underflow\n");
} else {
int x = stack[top--];
int y = stack[top--];
if (count< MAX_SIZE ) {
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+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCiNkZWZpbmUgTUFYX1NJWkUgMTAwCgoKICAgIGludCBzdGFja1tNQVhfU0laRV07CiAgICBpbnQgdG9wPS0xLGNvdW50PTA7CmludCBzaXplKCkKewpyZXR1cm4gY291bnQ7Cn0KCnZvaWQgcHVzaChpbnQgeCwgaW50IHkpCiB7CiAgICBpZiAoY291bnQrMjw9TUFYX1NJWkUgKQogewogICAgICAgIHN0YWNrWysrdG9wXSA9IHg7CiAgICAgICAgc3RhY2tbKyt0b3BdID0geTsKICAgICAgICBwcmludGYoIlB1c2hlZFxuIik7CiAgICB9IGVsc2UgewogICAgICAgIHByaW50ZigiT3ZlcmZsb3dcbiIpOwogICAgfQp9Cgp2b2lkIHBvcCgpIHsKICAgIGlmIChjb3VudDwgMikgewogICAgICAgIHByaW50ZigiVW5kZXJmbG93XG4iKTsKICAgIH0gZWxzZSB7CiAgICAgICAgaW50IHggPSBzdGFja1t0b3AtLV07CiAgICAgICAgaW50IHkgPSBzdGFja1t0b3AtLV07CiAgICAgICAgaWYgKGNvdW50PCBNQVhfU0laRSApIHsKICAgICAgICAgICAgc3RhY2tbKyt0b3BdID0geTsKICAgICAgICB9CiAgICB9Cn0KCnZvaWQgdG9wX2VsZW1lbnQoKQp7CiAgICBpZiAodG9wPT0gLTEpIHsKICAgICAgICBwcmludGYoIkVtcHR5XG4iKTsKICAgIH0gZWxzZSB7CiAgICAgICAgcHJpbnRmKCIlZFxuIiwgc3RhY2tbdG9wXSk7CiAgICB9Cn0KCmludCBtYWluKCkgewogICBzdGFjazsKICAgIHRvcCA9IC0xOwoKICAgIGludCBuOwogICAgc2NhbmYoIiVkIiwgJm4pOwoKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgaW50IGNvbW1hbmQ7CiAgICAgICAgc2NhbmYoIiVkIiwgJmNvbW1hbmQpOwoKICAgICAgICBpZiAoY29tbWFuZCA9PSAxKSB7CiAgICAgICAgICAgIGludCB4LCB5OwogICAgICAgICAgICBzY2FuZigiJWQgJWQiLCAmeCwgJnkpOwogICAgICAgICAgICBwdXNoKCB4LCB5KTsKICAgICAgICB9IGVsc2UgaWYgKGNvbW1hbmQgPT0gMikgewogICAgICAgICAgICBwb3AoKTsKICAgICAgICB9IGVsc2UgaWYgKGNvbW1hbmQgPT0gMykgewogICAgICAgICAgICB0b3BfZWxlbWVudCgpOwogICAgICAgIH0KICAgIH0KCiAgICByZXR1cm4gMDsKfQ==