#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;
count++;
stack[++top] = y;
count++;
printf("Pushed\n");
} else {
printf("Overflow\n");
}
}
void pop() {
if (count< 2) {
printf("Underflow\n");
} else {
int x = stack[top--];
count--;
int y = stack[top--];
count--;
int sum=x+y;
if (count< MAX_SIZE ) {
stack[++top] = sum;
}
}
}
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+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCiNkZWZpbmUgTUFYX1NJWkUgMTAwCgoKICAgIGludCBzdGFja1tNQVhfU0laRV07CiAgICBpbnQgdG9wPS0xLGNvdW50PTA7CmludCBzaXplKCkKewpyZXR1cm4gY291bnQ7Cn0KCnZvaWQgcHVzaChpbnQgeCwgaW50IHkpCiB7CiAgICBpZiAoY291bnQrMjw9TUFYX1NJWkUgKQogewogICAgICAgIHN0YWNrWysrdG9wXSA9IHg7CmNvdW50Kys7CiAgICAgICAgc3RhY2tbKyt0b3BdID0geTsKY291bnQrKzsKICAgICAgICBwcmludGYoIlB1c2hlZFxuIik7CiAgICB9IGVsc2UgewogICAgICAgIHByaW50ZigiT3ZlcmZsb3dcbiIpOwogICAgfQp9Cgp2b2lkIHBvcCgpIHsKICAgIGlmIChjb3VudDwgMikgewogICAgICAgIHByaW50ZigiVW5kZXJmbG93XG4iKTsKICAgIH0gZWxzZSB7CiAgICAgICAgaW50IHggPSBzdGFja1t0b3AtLV07CmNvdW50LS07CiAgICAgICAgaW50IHkgPSBzdGFja1t0b3AtLV07CmNvdW50LS07CmludCBzdW09eCt5OwoKICAgICAgICBpZiAoY291bnQ8IE1BWF9TSVpFICkgewogICAgICAgICAgICBzdGFja1srK3RvcF0gPSBzdW07CiAgICAgICAgfQogICAgfQp9Cgp2b2lkIHRvcF9lbGVtZW50KCkKewogICAgaWYgKHRvcD09IC0xKSB7CiAgICAgICAgcHJpbnRmKCJFbXB0eVxuIik7CiAgICB9IGVsc2UgewogICAgICAgIHByaW50ZigiJWRcbiIsIHN0YWNrW3RvcF0pOwogICAgfQp9CgppbnQgbWFpbigpIHsKICAgc3RhY2s7CiAgICB0b3AgPSAtMTsKCiAgICBpbnQgbjsKICAgIHNjYW5mKCIlZCIsICZuKTsKCiAgICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykgewogICAgICAgIGludCBjb21tYW5kOwogICAgICAgIHNjYW5mKCIlZCIsICZjb21tYW5kKTsKCiAgICAgICAgaWYgKGNvbW1hbmQgPT0gMSkgewogICAgICAgICAgICBpbnQgeCwgeTsKICAgICAgICAgICAgc2NhbmYoIiVkICVkIiwgJngsICZ5KTsKICAgICAgICAgICAgcHVzaCggeCwgeSk7CiAgICAgICAgfSBlbHNlIGlmIChjb21tYW5kID09IDIpIHsKICAgICAgICAgICAgcG9wKCk7CiAgICAgICAgfSBlbHNlIGlmIChjb21tYW5kID09IDMpIHsKICAgICAgICAgICAgdG9wX2VsZW1lbnQoKTsKICAgICAgICB9CiAgICB9CgogICAgcmV0dXJuIDA7Cn0=