#include <bits/stdc++.h>
using namespace std;
class node{
public:
int data;
node* next;
node(int d)
{
data =d;
next=NULL;
}
};
void inserttail(node*&head,int data){
noden=new node(data);
nodelast=head;
n->next=NULL;
if(head==NULL)
{
head=n;
return;
}
while(last->next!=NULL)
{
last=last->next;
}
last->next=n;
return;
}
void print(node*head)
{
while(head!=NULL)
{
cout<<head->data<<" ";
head=head->next;
}
cout<<endl;
}
node* merge(nodea,nodeb)
{
if(a==NULL)
{
return b;
}
if(b==NULL)
{
return a;
}
node*c;
if(a->data<b->data)
{
c=a;
c->next=merge(a->next,b);
}
else{
c=b;
c->next=merge(a,b->next);
}
return c;
}
int main()
{ int t;
cin>>t;
nodehead=NULL;
nodehead2=NULL;
while(t–)
{
int n;
cin>>n;
for(int i=0;i<n;i++)
{
int data;
cin>>data;
inserttail(head,data);
}
int nn;
cin>>nn;
for(int i=0;i<nn;i++)
{
int data;
cin>>data;
inserttail(head2,data);
}
}
head=merge(head,head2);
print(head);
}