// 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(1*sizeof(Node));
    newnode->id=v;
    newnode->ar=t;
    newnode->next=NULL'
    if(front==NULL){
        front=rear=newnode;
    }
    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,y;
        scanf("%d %d",&x,&y);
        if(x<=0 || y<0){
            printf("Invalid input");
            return 0;
        }
        enqueue(x,y);
    }
    dequeue();
    return 0;
}