// editor4
#include<stdio.h>
#include<stdlib.h>
typedef struct node{
    int id;
    int ar;
    struct node *next;
}node;
node *front=NULL,*rear=NULL;
void enqueue(int v ,int t){
    node*newnode=(node*)malloc(sizeof(node));
    newnode->id=v;
    newnode->ar=t;
    newnode->next=NULL;
    if(front == NULL){
        front = rear = newnode;
    return;
    }
    else{
        rear ->next = newnode;
        rear = newnode;
    }
}
void dequeue(){
if(front == NULL){
    printf("Queue is empty");
    return;
}
while(front != NULL){
    printf("%d\n",front->id);
    front = front->next;
}

int main(){
    int size;
    scanf("%d",&size);
    if(size<0){
        printf("Invalid input");
        return 0;
    }
    for(int i=0;i<size;i++){
        int x,int y;
        scanf("%d %d",&x,&y);
        if(x<0 || y<0){
            printf("Invalid input");
            return 0;
        }
            enqueue(x,y);
        }
        dequeue();
        return 0;
    }
}