// editor4
#include<stdio.h>
#include<stdlib.h>
typedef struct Node{
    int id;
    int arr;
    struct Node*next;
}node;

node*front=NULL,rear=NULL;
void enqueue(int v,int t){
    node*newnode=(node*)malloc(sizeof(node));
    newnode->v=id;
    newnode->t=arr;
    newnode->next=NULL;
    if(head==NULL){
        front=newnode;
        rear=newnode;
    }
    else{
        rear->next=newnode;
        rear=newnode;
    }
}
void dequeue(){
if(front==NULL){
    printf("queue is empty");
    return;
}
while(front !=NULL){
    printf("%d",front->id);
    front=front->next;
}
}
int main(){
    int size,x,y;
    scanf("%d",&size);
    if(size<0){
        printf("Invalid input");
        return 0;
    }
    for(int i=1;i<=size;i++){
        scanf("%d %d",&x,&y);
        if(x<0 || y<0 ){
            printf("Invalid input");
            return 0;
        }
        enqueue(x,y);
    }
    dequeue();
    return 0;
}