﻿namespace CompareCharArrays
{
    using System;
    using System.Linq;

    class Compare
    {
        static void Main()
        {
            char[] first = Console.ReadLine().Split(' ').Select(char.Parse).ToArray();
            char[] second = Console.ReadLine().Split(' ').Select(char.Parse).ToArray();

            if(first.Length > second.Length)
            {
                PrintResult(second, first);
                return;
            }

            for (int i = 0; i < first.Length; i++)
            {
                if(second[i] < first[i])
                {
                    PrintResult(second, first);
                    return;
                }
            }

            PrintResult(first, second);
        }

        public static void PrintResult(char[] first, char[] second)
        {
            Console.WriteLine(string.Join("", first));
            Console.WriteLine(string.Join("", second));
        }
    }
}
