using System;
using System.Linq;

public class HelloWorld
{
    public static void Main(string[] args)
    {
        int[] A = { 8, 2, 6, 4 };
        int[] B = { 9, 1, 5, 3, 7 };
        
     
        var combinedArray = A.Union(B).ToArray();

       
        for (int i = 0; i < combinedArray.Length - 1; i++)
        {
            for (int j = 0; j < combinedArray.Length - 1 - i; j++)
            {
                if (combinedArray[j] > combinedArray[j + 1])
                {
                    var temp = combinedArray[j];
                    combinedArray[j] = combinedArray[j + 1];
                    combinedArray[j + 1] = temp;
                }
            }
        }

        
        Console.Write(string.Join(" ", combinedArray));
        Console.WriteLine(" ");
    }
}