#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;
    }
    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");
    }
    for(int i=0; i<size; i++){
        int x,y;
        scanf("%d %d",&x,&y);
        enqueue(x,y);
    }
    dequeue();
    return 0;
}