#include<stdio.h>
#include<stdlib.h>
long long l=0;
struct node{
struct node* prev;
long long data;
struct node* next;
};
struct node* head;
void insert(long long x,long long p)
{
long long i;
struct node* temp1=(node*)malloc(sizeof(node));
temp1->data=x;
l++;
if(p==1)
{
temp1->next=head;
head=temp1;
head->prev=NULL;
}
else
{
struct node* temp2=head;
for(i=0;i<p-2;i++)
temp2=temp2->next;
temp1->prev=temp2;
temp1->next=temp2->next;
if(l!=p)
temp1->next->prev=temp1;
temp2->next=temp1;
}
}
void print()
{
struct node* temp=head;
while(temp!=NULL)
{
printf("%lld ",temp->data);
temp=temp->next;
}
}
int main()
{
long long n,i,p,x;
head=NULL;
scanf("%lld",&n);
for(i=0;i<n;i++)
{
scanf("%lld%lld",&x,&p);
insert(x,p);
print();
}
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8c3RkbGliLmg+CmxvbmcgbG9uZyBsPTA7CnN0cnVjdCBub2RlewoJc3RydWN0IG5vZGUqIHByZXY7Cglsb25nIGxvbmcgZGF0YTsKCXN0cnVjdCBub2RlKiBuZXh0Owp9OwpzdHJ1Y3Qgbm9kZSogaGVhZDsgCnZvaWQgaW5zZXJ0KGxvbmcgbG9uZyB4LGxvbmcgbG9uZyBwKQp7Cglsb25nIGxvbmcgaTsKCXN0cnVjdCBub2RlKiB0ZW1wMT0obm9kZSopbWFsbG9jKHNpemVvZihub2RlKSk7Cgl0ZW1wMS0+ZGF0YT14OwoJbCsrOwoJaWYocD09MSkKCXsKCQl0ZW1wMS0+bmV4dD1oZWFkOwoJCWhlYWQ9dGVtcDE7CgkJaGVhZC0+cHJldj1OVUxMOwoJfQoJZWxzZQoJewoJCXN0cnVjdCBub2RlKiB0ZW1wMj1oZWFkOwoJCWZvcihpPTA7aTxwLTI7aSsrKQoJCXRlbXAyPXRlbXAyLT5uZXh0OwoJCXRlbXAxLT5wcmV2PXRlbXAyOwoJCXRlbXAxLT5uZXh0PXRlbXAyLT5uZXh0OwoJCWlmKGwhPXApCgk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