#include<stdio.h>
#include<stdlib.h>
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;
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;
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+CnN0cnVjdCBub2RlewoJc3RydWN0IG5vZGUqIHByZXY7Cglsb25nIGxvbmcgZGF0YTsKCXN0cnVjdCBub2RlKiBuZXh0Owp9OwpzdHJ1Y3Qgbm9kZSogaGVhZDsgCnZvaWQgaW5zZXJ0KGxvbmcgbG9uZyB4LGxvbmcgbG9uZyBwKQp7Cglsb25nIGxvbmcgaTsKCXN0cnVjdCBub2RlKiB0ZW1wMT0obm9kZSopbWFsbG9jKHNpemVvZihub2RlKSk7Cgl0ZW1wMS0+ZGF0YT14OwoJaWYocD09MSkKCXsKCQl0ZW1wMS0+bmV4dD1oZWFkOwoJCWhlYWQ9dGVtcDE7CgkJaGVhZC0+cHJldj1OVUxMOwoJfQoJZWxzZQoJewoJCXN0cnVjdCBub2RlKiB0ZW1wMj1oZWFkOwoJCWZvcihpPTA7aTxwLTI7aSsrKQoJCXRlbXAyPXRlbXAyLT5uZXh0OwoJCXRlbXAxLT5wcmV2PXRlbXAyOwoJCXRlbXAxLT5uZXh0PXRlbXAyLT5uZXh0OwoJCXRlbXAxLT5uZXh0LT5wcmV2PXRlbXAxOwoJCXRlbXAyLT5uZXh0PXRlbXAxO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