#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 50

typedef struct Node {
    int label;
    struct Node* next;
} Node;

Node* front = NULL;
Node* rear = NULL;s

void enqueue(int label) {
    Node* newNode = (Node*)malloc(sizeof(Node));
    newNode->label = label;
    newNode->next = NULL;
    if (rear == NULL) {
        front = rear = newNode;
    } else {
        rear->next = newNode; 
        rear = newNode;
    }
}

void dequeue() {
    if (front == NULL) {
        printf("Invalid input\n");
        return;
    }
    printf("%d\n", front->label);
    Node* temp = front;
    front = front->next;
    if (front == NULL) rear = NULL;
    free(temp);
}

int main() {
    char input[MAX * 4];
    fgets(input, sizeof(input), stdin);

    char* token = strtok(input, " \n");
    while (token != NULL) {
        if (strcmp(token, "out") == 0) {
            dequeue();
        } else {
            int label = atoi(token);
            if (label >= 10 && label <= 99) {
                enqueue(label);
            }
        }
        token = strtok(NULL, " \n");
    }
    return 0;
}