#include <iostream>
using namespace std;
typedef struct LNode
{
int data;
struct LNode *next;
}LNode,*linkList;
void CreateList_R(linkList &L,int n)
{//后插法创建单链表
L=new LNode;
L->next=NULL;
linkList r=L;
for(int i=0;i<n;i++)
{
linkList p=new LNode;
cin>>p->data;
p->next=NULL;
r->next=p;
r=p;
}
}
void PrintList(linkList &L)
{//打印依次输出链表中的数据
L=L->next;
while(L){
if(L->next!=NULL) cout<<L->data<<" ";
else cout<<L->data;
L=L->next;
}
cout<<endl;
}
void MergeList(linkList &LA,linkList &LB,linkList &LC)
{//求基于链表的两个非递减有序序列的合并
/**************begin************/
/**************end************/
}
int main()
{
int n,m;
while(cin>>n>>m)
{
if(n==0&&m==0) break;
linkList LA,LB,LC;
CreateList_R(LA,n);
CreateList_R(LB,m);
MergeList(LA,LB,LC);
PrintList(LC);
}
return 0;
}