#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();
	}
}
