#include<stdio.h>
#include<stdlib.h>
struct node{
    int id;
    int time;
    struct node *next;
};
int main(){
    int n,id, time;
    struct node*fromnt = 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->nexyt=temp;
                rear=temp;
            }
        }
        while(front != NULL) {
            printf("%d\n", front->id);
            front=front->next;
        }
        return 0;
    }