#include<bits/stdc++.h>
using namespace std;
struct node{
int data;
node* next;
};
node* createlist()
{
node* head ,*end,*p;
head=new struct node;
end=head;
end->next =NULL;
int k;
while(cin>>k&&k!=-1)
{ p=new struct node;
p->data=k;
end->next=p;
end=p;
}
end->next=NULL;
return head->next;
}
node* operate( node* p1, node* p2)
{
if(!p1&&!p2)
return NULL;
else if(!p1)
{
return p2;
}
else if(!p2)
{
return p1;
}
else
{
node* head ,*end;
if(p1->data>=p2->data)
{
head=p2;
end=p2;
p2=p2->next;
}
else if(p1->data<p2->data)
{
head=p1;
end=p1;
p1=p1->next;
}
while(p1&&p2)
{
if(p1->data>=p2->data)
{
end->next=p2;
end=p2;
p2=p2->next;
}
else if(p1->data<p2->data)
{
end->next=p1;
end=p1;
p1=p1->next;
}
}
if(!p1)
{
end->next=p2;
}
else if(!p2)
{
end->next=p1;
}
return head;
}
}
int main()
{ int flag = 0;
struct node*p1,*p2,*p3;
p1=createlist();
p2=createlist();
p3=operate(p1,p2);
if(!p3)
{
cout<<"NULL";
}
else
{
while(p3)
{
if(flag)printf(" %d",p3 -> data);
else printf("%d",p3 -> data);
p3= p3 -> next;
flag = 1;
}
}
}