#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",front->id);
        front=front->next;
    }
    return 0;
}