#include <stdio.h>
#include <stdlib.h>
struct node
{
int data;
struct node *next;
}*p, *q1, *q2, *head1, *head2;
int main()
{
int n, m;
struct node *q, *head;
scanf("%d%d", &m, &n);
head1 = (struct node*)malloc(sizeof(struct node));
head1->next = NULL;
q1 = head1;
while(m--)
{
p = (struct node*)malloc(sizeof(struct node));
scanf("%d", &p->data);
p->next = NULL;
q1->next = p;
q1 = p;
}
head2 = (struct node*)malloc(sizeof(struct node));
head2->next = NULL;
q2 = head2;
while(n--)
{
p = (struct node*)malloc(sizeof(struct node));
scanf("%d", &p->data);
p->next = NULL;
q2 ->next = p;
q2 = p;
}
q1 = head1->next;
q2 = head2->next;
head = head1;
q = head1;
while(q1&&q2)
{
if(q1->data < q2->data)
{
q->next = q1;
q = q1;
q1 = q1->next;
}
else
{
q->next = q2;
q = q2;
q2 = q2->next;
}
}
if(q1)
q->next = q1;
else
q->next = q2;
q = head->next;
while(q->next)
{
printf("%d ", q->data);
q = q->next;
}
printf("%d", q->data);
printf("\n");
return 0;
}