#include<stdio.h>
#include<strlib.h>
#include<string.h>
#include<ctype.h>

typedef struct N{int v; struct N*next;}N;
int main(){
    N*f=0,*r=0,*t;
    char x[20];
    while (scanf("%19s",x)==1)
        if(!strcmp(x,"out")){
            if(!f){puts("Invalid input"); return 0;}
            printf("%d\n",f->v);
            t=f;f=f->next;if(!f) r=0;free(t);
        }else{
            for (char*p=x;*p;p++) if(!isdigit(*p)){puts("Invalid input");return 0;}
            intr v=atoi(x);
            if(v<10||v>99){puts("invalid input");return 0;}
            t=malloc(sizeof(N));
            t->v=v; t->next=0;
            if(!r) f=r=t;
            else{r->next=t;r=t;}
            
            
            
        }
}