#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
    int data;
    struct Node *next;
};

struct Node *front = NULL, *rear = NULL;

// Enqueue (add box)
void enqueue(int val) {
    struct Node newNode = (struct Node)malloc(sizeof(struct Node));
    newNode->data = val;
    newNode->next = NULL;

    if (rear == NULL) {
        front = rear = newNode;
    } else {
        rear->next = newNode;   // required condition
        rear = newNode;
    }
}

// Dequeue (dispatch box)
void dequeue() {
    if (front == NULL) {
        printf("Invalid input\n");
        exit(0);
    }
    struct Node *temp = front;
    printf("%d\n", temp->data);
    front = front->next;
    if (front == NULL) rear = NULL;
    free(temp);
}

int main() {
    char input[500];
    fgets(input, sizeof(input), stdin);

    char *token = strtok(input, " \t\n");
    while (token != NULL) {
        if (strcmp(token, "out") == 0) {
            dequeue();
        } else {
            int val = atoi(token);
            if (val < 10 || val > 99) {
                printf("Invalid input\n");
                return 0;
            }
            enqueue(val);
        }
        token = strtok(NULL, " \t\n");
    }
    return 0;