struct node
{
int data;
struct node*next;
};
struct node *head;
int len;
void print(struct node * head)
{
struct node *p;
p=head->next;
while(p!=NULL)
{
printf("%d",p->data);
if(p->next!=NULL)
{
printf(" ");
}
else
{
printf("\n");
}
p=p->next;
}
}
void insert(int mi,int xi)
{
struct node *p,*q;
int i;
p=head;
for(i=1; i<=mi&&i<=len; i++)
{
p=p->next;
}
q=(struct node *)malloc(sizeof(struct node));
q->data=xi;
q->next=NULL;
q->next=p->next;
p->next=q;
len++;
}
int main()
{
int n,i,xi,mi;
while(scanf("%d",&n)!=EOF)
{
head=(struct node *)malloc(sizeof(struct node));
head->next=NULL;
len=0;
for(i=1; i<=n; i++)
{
scanf("%d %d",&mi,&xi);
insert(mi,xi);
}
print(head);
}
return 0;
}
struct node
{
int data;
struct node*next;
};
struct node *head;
int len;
void print(struct node * head)
{
struct node *p;
p=head->next;
while(p!=NULL)
{
printf("%d",p->data);
if(p->next!=NULL)
{
printf(" ");
}
else
{
printf("\n");
}
p=p->next;
}
}
void insert(int m,int x)
{
struct node *p,*q,*t;
int i;
p=head;
q=p->next;
for(i=1; i<=m&&i<=len; i++)
{
p=p->next;
q=q->next;
}
t=(struct node *)malloc(sizeof(struct node));
t->data=x;
t->next=NULL;
p->next=t;
t->next=q;
len++;
}
int main()
{
int n,i,x,m;
while(scanf("%d",&n)!=EOF)
{
head=(struct node *)malloc(sizeof(struct node));
head->next=NULL;
len=0;
for(i=1; i<=n; i++)
{
scanf("%d %d",&m,&x);
insert(m,x);
}
print(head);
}
return 0;
}