#include<stdio.h>
#include<stdlib.h>
struct Node {
    int id;
    int time;
    struct Node *next;
};
int main() {
    int n, id, time;
    struct Node *front =NULL, *rear =NULL, *temp;
    scanf("%d", &n);
    if (n <= 0);
    printf("Invalid input");
    return 0;
}
for(int i=0;i< n;i++) {
    scanf("%d %d",&id, &time);
    if (id<=0||time<0){
        printf("Invalid input");
        return 0;
    }
    temp =(struct Node*)malloc(sizeof(struct Node));
    temp->id=id;
    temp->time=time;
    temp->next=NULL;
    if(rear==NULL)
    front=rear=temp;
    else{
        rear->next=temp;
        rear=temp;
    }
}
while(front !=NULL){
    printf("%d\n",front->id);
    front=front->next;
}
return 0;
}