#include<stdio.h>
#include<stdlib.h>
typedef struct node{
    int id;
    int arr;
    struct node *next;
}Node;
Node *front=NULL,*tail=NULL;
void enque(int x,int y){
    Node *newnode=(Node*)malloc(sizeof(Node));
    newnode->id=x;
    newnode->arr=y;
    newnode-next=NULL;
    if(front==NULL){
        front=newnode;
        rear=newnode;
    }
    else{
        rear->next=newnode;
        rear=newnode;
    }
}
void deque(){
    if(front==NULL){
        printf("Queue is empty");
        return;
    }
    while(front!=NULL){
        printf("%d\n",front->id);
        front=front->next;
    }
}
int main(){
    int n;
    scanf("%d",&n);
    if(n<0){
        printf("Invalid input");
        return 0;
    }
    for(int i=0;i<n;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        enque(x,y);
    }
    deque();
    return 0;
}