#include <iostream>
using namespace std;
void swap(int* a, int* b);
int main()
{
int m, n;
int arr1[1000] = { 0 };
int arr2[1000] = { 0 };
int arr3[1000] = { 0 };
int count1 = 0, count2 = 0;
cin >> m >> n;
for (int i = 0; i < m; i++)
{
cin >> arr1[i];
count1++;
}
for (int i = 0; i < n; i++)
{
cin >> arr2[i];
count2++;
}
for (int i = 0; i < m ; i++)
{
arr3[i] = arr1[i];
if (i == m - 1)
{
for (int j = 0; j < n; j++)
{
arr3[m + j] = arr2[j];
}
}
}
for (int i = 0; i <m+n; i++)
{
int min = i;
for (int j = i + 1; j < m+n; j++)
{
if (arr3[min] > arr3[j])
{
min = j;
}
}
swap(&arr3[min], &arr3[i]);
}
for (int i = 0; i < m + n; i++)
{
cout << arr3[i]<<" ";
}
}
void swap(int* a, int* b)
{
int temp = *a;
*a = *b;
*b = temp;
}
using namespace std;
void swap(int* a, int* b);
int main()
{
int m, n;
int arr1[1000] = { 0 };
int arr2[1000] = { 0 };
int arr3[1000] = { 0 };
int count1 = 0, count2 = 0;
cin >> m >> n;
for (int i = 0; i < m; i++)
{
cin >> arr1[i];
count1++;
}
for (int i = 0; i < n; i++)
{
cin >> arr2[i];
count2++;
}
for (int i = 0; i < m ; i++)
{
arr3[i] = arr1[i];
if (i == m - 1)
{
for (int j = 0; j < n; j++)
{
arr3[m + j] = arr2[j];
}
}
}
for (int i = 0; i <m+n; i++)
{
int min = i;
for (int j = i + 1; j < m+n; j++)
{
if (arr3[min] > arr3[j])
{
min = j;
}
}
swap(&arr3[min], &arr3[i]);
}
for (int i = 0; i < m + n; i++)
{
cout << arr3[i]<<" ";
}
}
void swap(int* a, int* b)
{
int temp = *a;
*a = *b;
*b = temp;
}