#include <stdio.h>
#include <iostream.h>

int main()
{
    int list1[20], list2[20], n1, n2, k = 0, min = 1000,res[20],flag=0,Q=0;
    
    printf("Enter the number of elements in list1 and list2: ");
    scanf("%d %d", &n1, &n2);
    
    for (int i = 0; i < n1; i++)
    {
        scanf("%d", &list1[i]);
    }

    for (int i = 0; i < n2; i++)
    {
        scanf("%d", &list2[i]);
    }

    for (int i = n1-1; i < n1 + n2-1; i++)
    {
        list1[i] = list2[k];
        k++;
    }

    for (int i = 0; i < n1 + n2; i++)
    {
        for (int j = 0; j < n1 + n2; j++)
        {
            if (min > list1[j])
            {
                min = list1[j];
            }
        }
        list1[j-1] = 111222333;