Getting closer and closer to a mathematician, Serval becomes a university student on math major in Japari University. On the Calculus class, his teacher taught him how to calculate the expected length of a random subsegment of a given segment. Then he left a bonus problem as homework, with the award of a garage kit from IOI. The bonus is to extend this problem to the general case as follows.You are given a segment with length $$$l$$$. We randomly choose $$$n$$$ segments by choosing two points (maybe with non-integer coordinates) from the given segment equiprobably and the interval between the two points forms a segment. You are given the number of random segments $$$n$$$, and another integer $$$k$$$. The $$$2n$$$ endpoints of the chosen segments split the segment into $$$(2n+1)$$$ intervals. Your task is to calculate the expected total length of those intervals that are covered by at least $$$k$$$ segments of the $$$n$$$ random segments.You should find the answer modulo $$$998244353$$$.

First line contains three space-separated positive integers $$$n$$$, $$$k$$$ and $$$l$$$ ($$$1\leq k \leq n \leq 2000$$$, $$$1\leq l\leq 10^9$$$).

Output one integer — the expected total length of all the intervals covered by at least $$$k$$$ segments of the $$$n$$$ random segments modulo $$$998244353$$$. Formally, let $$$M = 998244353$$$. It can be shown that the answer can be expressed as an irreducible fraction $$$\frac{p}{q}$$$, where $$$p$$$ and $$$q$$$ are integers and $$$q \not \equiv 0 \pmod{M}$$$. Output the integer equal to $$$p \cdot q^{-1} \bmod M$$$. In other words, output such an integer $$$x$$$ that $$$0 \le x < M$$$ and $$$x \cdot q \equiv p \pmod{M}$$$.

NoteIn the first example, the expected total length is $$$\int_0^1 \int_0^1 |x-y| \,\mathrm{d}x\,\mathrm{d}y = {1\over 3}$$$, and $$$3^{-1}$$$ modulo $$$998244353$$$ is $$$332748118$$$.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;

namespace ReadWriteTemplate
{
    public static class Solver
    {
        private static void SolveCase()
        {
            const long MOD = 998244353;

            int n = ReadInt();
            int k = ReadInt();
            long l = ReadInt();

            int N = 2 * n + 2;
            long[][,] a = new long[2][,];
            a[0] = new long[N, 2];
            a[0][0, 0] = 1;

            for (int i = 0; i < 2 * n + 1; i++)
            {
                int t = i % 2;
                a[1 - t] = new long[N, 2];
                for (int j = 0; j <= i; j++)
                {
                    for (int e = 0; e < 2; e++)
                    {
                        if (e == 0 && j >= k)
                        {
                            a[1 - t][j, 1] += a[t][j, e];
                            Fix(ref a[1 - t][j, 1], MOD);
                        }
                        if (j > 0)
                        {
                            a[1 - t][j - 1, e] = (a[1 - t][j - 1, e] + j * a[t][j, e]) % MOD;
                        }
                        if (i + j - e <= 2 * n - 2)
                        {
                            a[1 - t][j + 1, e] += a[t][j, e];
                            Fix(ref a[1 - t][j + 1, e], MOD);
                        }
                    }
                }
            }

            long ans = a[1][0, 1];
            ans = ans * BinPower(2, n, MOD) % MOD;
            ans = ans * l % MOD;

            long f = 1;
            for (int i = 1; i <= n; i++)
            {
                f = f * i % MOD;
            }
            ans = ans * f % MOD;
            for (int i = n + 1; i <= 2 * n + 1; i++)
            {
                f = f * i % MOD;
            }
            ans = ans * Inv(f, MOD) % MOD;

            Writer.WriteLine(ans);
        }

        public static void Fix(ref long x, long mod)
        {
            if (x >= mod)
            {
                x -= mod;
            }
        }

        public static long Inv(long a, long mod)
        {
            return BinPower(a, mod - 2, mod);
        }

        public static long BinPower(long a, long n, long mod)
        {
            long result = 1;

            while (n > 0)
            {
                if ((n & 1) != 0)
                {
                    result = (result * a) % mod;
                }

                a = (a * a) % mod;
                n >>= 1;
            }

            return result;
        }

        public static void Solve()
        {
#if DEBUG
            var sw = Stopwatch.StartNew();
#endif

            SolveCase();

            /*int T = ReadInt();
            for (int i = 0; i < T; i++)
            {
                Writer.Write("Case #{0}: ", 1 - t);
                SolveCase();
            }*/

#if DEBUG
            sw.Stop();
            Console.WriteLine($"{sw.ElapsedMilliseconds} ms");
#endif
        }

        public static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

#if DEBUG
            // Reader = Console.In; Writer = Console.Out;
            Reader = File.OpenText("input.txt"); Writer = File.CreateText("output.txt");
#else
            Reader = Console.In; Writer = Console.Out;
#endif

            // Solve();
            Thread thread = new Thread(Solve);
            thread.CurrentCulture = CultureInfo.InvariantCulture;
            thread.Start();
            thread.Join();

            Reader.Close();
            Writer.Close();
        }

        public static IOrderedEnumerable<TSource> OrderByWithShuffle<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
        {
            return source.Shuffle().OrderBy(keySelector);
        }

        public static T[] Shuffle<T>(this IEnumerable<T> source)
        {
            T[] result = source.ToArray();
            Shuffle(result);
            return result;
        }

        private static void Shuffle<T>(IList<T> array)
        {
            Random rnd = new Random();
            for (int i = array.Count - 1; i >= 1; i--)
            {
                int k = rnd.Next(i + 1);
                T tmp = array[k];
                array[k] = array[i];
                array[i] = tmp;
            }
        }

        #region Read/Write

        private static TextReader Reader;

        private static TextWriter Writer;

        private static Queue<string> CurrentLineTokens = new Queue<string>();

        private static string[] ReadAndSplitLine()
        {
            return Reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        }

        public static string ReadToken()
        {
            while (CurrentLineTokens.Count == 0)
                CurrentLineTokens = new Queue<string>(ReadAndSplitLine());
            return CurrentLineTokens.Dequeue();
        }

        public static string ReadLine()
        {
            return Reader.ReadLine();
        }

        public static int ReadInt()
        {
            return int.Parse(ReadToken());
        }

        public static long ReadLong()
        {
            return long.Parse(ReadToken());
        }

        public static double ReadDouble()
        {
            return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
        }

        public static int[] ReadIntArray()
        {
            return ReadAndSplitLine().Select(int.Parse).ToArray();
        }

        public static long[] ReadLongArray()
        {
            return ReadAndSplitLine().Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
        }

        public static int[][] ReadIntMatrix(int numberOfRows)
        {
            int[][] matrix = new int[numberOfRows][];
            for (int i = 0; i < numberOfRows; i++)
                matrix[i] = ReadIntArray();
            return matrix;
        }

        public static string[] ReadLines(int quantity)
        {
            string[] lines = new string[quantity];
            for (int i = 0; i < quantity; i++)
                lines[i] = Reader.ReadLine().Trim();
            return lines;
        }

        public static void WriteArray<T>(IEnumerable<T> array)
        {
            Writer.WriteLine(string.Join(" ", array));
        }

        #endregion
    }
}

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;

namespace ReadWriteTemplate
{
    public static class Solver
    {
        private static void SolveCase()
        {
            const long MOD = 998244353;

            int n = ReadInt();
            int k = ReadInt();
            long l = ReadInt();

            int N = 2 * n + 2;
            long[][,] a = new long[2][,];
            long[][,] b = new long[2][,];
            a[0] = new long[N, 2];
            b[0] = new long[N, 2];
            a[0][0, 0] = 1;
            b[0][0, 0] = 1;

            for (int i = 0; i < 2 * n + 1; i++)
            {
                int t = i % 2;
                a[1 - t] = new long[N, 2];
                b[1 - t] = new long[N, 2];
                for (int j = 0; j <= i; j++)
                {
                    for (int e = 0; e < 2; e++)
                    {
                        if (e == 0)
                        {
                            if (j >= k)
                            {
                                a[1 - t][j, 1] += a[t][j, e];
                                Fix(ref a[1 - t][j, 1], MOD);
                            }
                            b[1 - t][j, 1] += b[t][j, e];
                            Fix(ref b[1 - t][j, 1], MOD);
                        }
                        if (j > 0)
                        {
                            a[1 - t][j - 1, e] = (a[1 - t][j - 1, e] + j * a[t][j, e]) % MOD;
                            b[1 - t][j - 1, e] = (b[1 - t][j - 1, e] + j * b[t][j, e]) % MOD;
                        }
                        if (i + j - e <= 2 * n - 2)
                        {
                            a[1 - t][j + 1, e] += a[t][j, e];
                            Fix(ref a[1 - t][j + 1, e], MOD);
                            b[1 - t][j + 1, e] += b[t][j, e];
                            Fix(ref b[1 - t][j + 1, e], MOD);
                        }
                    }
                }
            }

            long ans = a[1][0, 1] * Inv(b[1][0, 1], MOD) % MOD;
            ans = ans * l % MOD;

            Writer.WriteLine(ans);
        }

        public static void Fix(ref long x, long mod)
        {
            if (x >= mod)
            {
                x -= mod;
            }
        }

        public static long Inv(long a, long mod)
        {
            return BinPower(a, mod - 2, mod);
        }

        public static long BinPower(long a, long n, long mod)
        {
            long result = 1;

            while (n > 0)
            {
                if ((n & 1) != 0)
                {
                    result = (result * a) % mod;
                }

                a = (a * a) % mod;
                n >>= 1;
            }

            return result;
        }

        public static void Solve()
        {
#if DEBUG
            var sw = Stopwatch.StartNew();
#endif

            SolveCase();

            /*int T = ReadInt();
            for (int i = 0; i < T; i++)
            {
                Writer.Write("Case #{0}: ", 1 - t);
                SolveCase();
            }*/

#if DEBUG
            sw.Stop();
            Console.WriteLine($"{sw.ElapsedMilliseconds} ms");
#endif
        }

        public static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

#if DEBUG
            // Reader = Console.In; Writer = Console.Out;
            Reader = File.OpenText("input.txt"); Writer = File.CreateText("output.txt");
#else
            Reader = Console.In; Writer = Console.Out;
#endif

            // Solve();
            Thread thread = new Thread(Solve, 64 * 1024 * 1024);
            thread.CurrentCulture = CultureInfo.InvariantCulture;
            thread.Start();
            thread.Join();

            Reader.Close();
            Writer.Close();
        }

        public static IOrderedEnumerable<TSource> OrderByWithShuffle<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
        {
            return source.Shuffle().OrderBy(keySelector);
        }

        public static T[] Shuffle<T>(this IEnumerable<T> source)
        {
            T[] result = source.ToArray();
            Shuffle(result);
            return result;
        }

        private static void Shuffle<T>(IList<T> array)
        {
            Random rnd = new Random();
            for (int i = array.Count - 1; i >= 1; i--)
            {
                int k = rnd.Next(i + 1);
                T tmp = array[k];
                array[k] = array[i];
                array[i] = tmp;
            }
        }

        #region Read/Write

        private static TextReader Reader;

        private static TextWriter Writer;

        private static Queue<string> CurrentLineTokens = new Queue<string>();

        private static string[] ReadAndSplitLine()
        {
            return Reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        }

        public static string ReadToken()
        {
            while (CurrentLineTokens.Count == 0)
                CurrentLineTokens = new Queue<string>(ReadAndSplitLine());
            return CurrentLineTokens.Dequeue();
        }

        public static string ReadLine()
        {
            return Reader.ReadLine();
        }

        public static int ReadInt()
        {
            return int.Parse(ReadToken());
        }

        public static long ReadLong()
        {
            return long.Parse(ReadToken());
        }

        public static double ReadDouble()
        {
            return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
        }

        public static int[] ReadIntArray()
        {
            return ReadAndSplitLine().Select(int.Parse).ToArray();
        }

        public static long[] ReadLongArray()
        {
            return ReadAndSplitLine().Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
        }

        public static int[][] ReadIntMatrix(int numberOfRows)
        {
            int[][] matrix = new int[numberOfRows][];
            for (int i = 0; i < numberOfRows; i++)
                matrix[i] = ReadIntArray();
            return matrix;
        }

        public static string[] ReadLines(int quantity)
        {
            string[] lines = new string[quantity];
            for (int i = 0; i < quantity; i++)
                lines[i] = Reader.ReadLine().Trim();
            return lines;
        }

        public static void WriteArray<T>(IEnumerable<T> array)
        {
            Writer.WriteLine(string.Join(" ", array));
        }

        #endregion
    }
}

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;

namespace ReadWriteTemplate
{
    public static class Solver
    {
        private static void SolveCase()
        {
            const long MOD = 998244353;

            int n = ReadInt();
            int k = ReadInt();
            long l = ReadInt();

            int N = 2 * n + 2;
            long[][,] a = new long[2][,];
            a[0] = new long[N, 2];
            a[0][0, 0] = 1;

            for (int i = 0; i < 2 * n + 1; i++)
            {
                int t = i % 2;
                a[1 - t] = new long[N, 2];
                for (int j = 0; j <= i; j++)
                {
                    for (int e = 0; e < 2; e++)
                    {
                        if (e == 0 && j >= k)
                        {
                            a[1 - t][j, 1] += a[t][j, e];
                            Fix(ref a[1 - t][j, 1], MOD);
                        }
                        if (j > 0)
                        {
                            a[1 - t][j - 1, e] = (a[1 - t][j - 1, e] + j * a[t][j, e]) % MOD;
                        }
                        if (i + j - e <= 2 * n - 2)
                        {
                            a[1 - t][j + 1, e] += a[t][j, e];
                            Fix(ref a[1 - t][j + 1, e], MOD);
                        }
                    }
                }
            }

            long ans = a[1][0, 1];
            ans = ans * BinPower(2, n, MOD) % MOD;
            ans = ans * l % MOD;

            long f = 1;
            for (int i = 1; i <= n; i++)
            {
                f = f * i % MOD;
            }
            ans = ans * f % MOD;
            for (int i = n + 1; i <= 2 * n + 1; i++)
            {
                f = f * i % MOD;
            }
            ans = ans * Inv(f, MOD) % MOD;

            Writer.WriteLine(ans);
        }

        public static void Fix(ref long x, long mod)
        {
            if (x >= mod)
            {
                x -= mod;
            }
        }

        public static long Inv(long a, long mod)
        {
            return BinPower(a, mod - 2, mod);
        }

        public static long BinPower(long a, long n, long mod)
        {
            long result = 1;

            while (n > 0)
            {
                if ((n & 1) != 0)
                {
                    result = (result * a) % mod;
                }

                a = (a * a) % mod;
                n >>= 1;
            }

            return result;
        }

        public static void Solve()
        {
#if DEBUG
            var sw = Stopwatch.StartNew();
#endif

            SolveCase();

            /*int T = ReadInt();
            for (int i = 0; i < T; i++)
            {
                Writer.Write("Case #{0}: ", 1 - t);
                SolveCase();
            }*/

#if DEBUG
            sw.Stop();
            Console.WriteLine($"{sw.ElapsedMilliseconds} ms");
#endif
        }

        public static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

#if DEBUG
            // Reader = Console.In; Writer = Console.Out;
            Reader = File.OpenText("input.txt"); Writer = File.CreateText("output.txt");
#else
            Reader = Console.In; Writer = Console.Out;
#endif

            // Solve();
            Thread thread = new Thread(Solve, 64 * 1024 * 1024);
            thread.CurrentCulture = CultureInfo.InvariantCulture;
            thread.Start();
            thread.Join();

            Reader.Close();
            Writer.Close();
        }

        public static IOrderedEnumerable<TSource> OrderByWithShuffle<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
        {
            return source.Shuffle().OrderBy(keySelector);
        }

        public static T[] Shuffle<T>(this IEnumerable<T> source)
        {
            T[] result = source.ToArray();
            Shuffle(result);
            return result;
        }

        private static void Shuffle<T>(IList<T> array)
        {
            Random rnd = new Random();
            for (int i = array.Count - 1; i >= 1; i--)
            {
                int k = rnd.Next(i + 1);
                T tmp = array[k];
                array[k] = array[i];
                array[i] = tmp;
            }
        }

        #region Read/Write

        private static TextReader Reader;

        private static TextWriter Writer;

        private static Queue<string> CurrentLineTokens = new Queue<string>();

        private static string[] ReadAndSplitLine()
        {
            return Reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        }

        public static string ReadToken()
        {
            while (CurrentLineTokens.Count == 0)
                CurrentLineTokens = new Queue<string>(ReadAndSplitLine());
            return CurrentLineTokens.Dequeue();
        }

        public static string ReadLine()
        {
            return Reader.ReadLine();
        }

        public static int ReadInt()
        {
            return int.Parse(ReadToken());
        }

        public static long ReadLong()
        {
            return long.Parse(ReadToken());
        }

        public static double ReadDouble()
        {
            return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
        }

        public static int[] ReadIntArray()
        {
            return ReadAndSplitLine().Select(int.Parse).ToArray();
        }

        public static long[] ReadLongArray()
        {
            return ReadAndSplitLine().Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
        }

        public static int[][] ReadIntMatrix(int numberOfRows)
        {
            int[][] matrix = new int[numberOfRows][];
            for (int i = 0; i < numberOfRows; i++)
                matrix[i] = ReadIntArray();
            return matrix;
        }

        public static string[] ReadLines(int quantity)
        {
            string[] lines = new string[quantity];
            for (int i = 0; i < quantity; i++)
                lines[i] = Reader.ReadLine().Trim();
            return lines;
        }

        public static void WriteArray<T>(IEnumerable<T> array)
        {
            Writer.WriteLine(string.Join(" ", array));
        }

        #endregion
    }
}


The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the full name. Typically there are multiple possible logins for each person.You are given the first and the last name of a user. Return the alphabetically earliest login they can get (regardless of other potential Polygon users).As a reminder, a prefix of a string s is its substring which occurs at the beginning of s: "a", "ab", "abc" etc. are prefixes of string "{abcdef}" but "b" and 'bc" are not. A string a is alphabetically earlier than a string b, if a is a prefix of b, or a and b coincide up to some position, and then a has a letter that is alphabetically earlier than the corresponding letter in b: "a" and "ab" are alphabetically earlier than "ac" but "b" and "ba" are alphabetically later than "ac".

The input consists of a single line containing two space-separated strings: the first and the last names. Each character of each string is a lowercase English letter. The length of each string is between 1 and 10, inclusive.

Output a single string — alphabetically earliest possible login formed from these names. The output should be given in lowercase as well.

using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace Rextester {
    public class Program {
        public static void Main(string[] args) {
            string[] inputs = Console.ReadLine().Split();
            string first = inputs[0];
            string last = inputs[1];
            string ret = Convert.ToString(first[0]);
            for(int i = 1; i < first.Length; i++) {
                if(first[i] < last[0]) ret += first[i];
                else break;
            }

            ret += last[0];
            Console.WriteLine(ret);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

namespace CodeforcesTemplateClean
{
    class Program
    {

        public static bool IsPalindrome(BigInteger n)
        {
            BigInteger flip = 0;
            for (BigInteger i = n; i > 0; i /= 10)
            {
                flip = flip * 10 + (i % 10);
            }

            return n == flip;
        }

        static void Main(string[] args)
        {

            string[] array = Console.ReadLine().Split(' ');

            string name = array[0];

            char sName = array[1][0];

            int x = name.Length;

            for (int i = 1; i < name.Length; i++)
            {

               if (name[i] >= sName)
                {
                    x = i;

                    break;
                }
            }

            StringBuilder answerBuilder = new StringBuilder();

            for (int i = 0; i < x; i++)
            {
                answerBuilder.Append(name[i]);
            }

            answerBuilder.Append(sName);

            Console.WriteLine(answerBuilder);

           // Console.ReadKey();
        }

    }

    public static class Permutation
    {
        private static bool Next(ref int[] arr)
        {
            int k, j, l;
            for (j = arr.Length - 2; (j >= 0) && (arr[j] >= arr[j + 1]); j--) { }
            if (j == -1)
            {
                arr = arr.OrderBy(c => c).ToArray();
                return false;
            }
            for (l = arr.Length - 1; (arr[j] >= arr[l]) && (l >= 0); l--) { }
            var tmp = arr[j];
            arr[j] = arr[l];
            arr[l] = tmp;
            for (k = j + 1, l = arr.Length - 1; k < l; k++, l--)
            {
                tmp = arr[k];
                arr[k] = arr[l];
                arr[l] = tmp;
            }
            return true;
        }
        public static IEnumerable<int[]> AllPermutations(int[] arr)
        {
            do yield return arr;
            while (Next(ref arr));
        }
    }
}

using System;
using System.Linq;
using System.Text;

namespace trash
{
    class Program
    {
        static void Main()
        {
            string[] input = Console.ReadLine().Split();
            char[] name = input[0].ToCharArray();
            char lastLetter = input[1].First();
            var namePrefix = new StringBuilder(name[0].ToString());

            for (int i = 1; i < name.Length && name[i] < lastLetter; i++)
            {
                namePrefix.Append(name[i]);
            }
            Console.WriteLine("{0}{1}", namePrefix, lastLetter);
        }
    }
}

using System;
class Login
{
    public static void Main()
    {
        string st=Console.ReadLine();
        string[] s=st.Split(' ');
        string first=s[0];
        string last=s[1];
        string res=first[0].ToString();
        int i=1;
        while (i<first.Length && first[i]-last[0]<0)
        {
            res+=first[i];
            i++;
        }
        res+=last[0];
        Console.WriteLine(res);

    }
}

using System;
using System.Collections.Generic;

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');

            string fName = str[0];
            string lName = str[1];

            List<string> list = new List<string>();
            for (int i = 1; i <= fName.Length; i++)
            {
                for (int j = 1; j <= lName.Length; j++)
                {
                    var s = fName.Substring(0, i);
                    list.Add(fName.Substring(0, i) + lName.Substring(0, j));
                }
            }

            list.Sort();

            Console.WriteLine(list[0]);

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Генерация_логина
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] S = Console.ReadLine().Split();
            List<string> List = new List<string>();
            String s1, s2;
            for(int i=0;i<S[0].Count();i++)
            {
                s1 = ""; for (int j = 0; j <= i; j++) s1 += S[0][j];

                for (int e = 0; e < S[1].Count(); e++)
                {
                    s2 = ""; for (int j = 0; j <= e; j++) s2 += S[1][j];
                    List.Add(s1+s2);
                }
            }
            List.Sort();
            Console.WriteLine(List[0]);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GeneracijaLogina
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            StringBuilder login = new StringBuilder();
            login.Append(s[0][0]);
            int i = 1;
            while (i<s[0].Length && s[0][i]<s[1][0])
            {
                login.Append(s[0][i]);
                i++;
            }

            login.Append(s[1][0]);
            Console.Write(login.ToString());

        }
    }
}

using System;
using System.IO;
using System.Text;

namespace Generate_Login
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve(args));
            writer.Flush();
        }

        private static string Solve(string[] args)
        {
            string[] ss = reader.ReadLine().Split(' ');

            for (int i = 1; i < ss[0].Length; i++)
            {
                if (ss[0][i] >= ss[1][0])
                    return ss[0].Substring(0, i) + ss[1].Substring(0, 1);
            }

            return ss[0] + ss[1].Substring(0, 1);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

namespace hr_harness
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            string first = input[0];
            string last = input[1];
            StringBuilder output = new StringBuilder(first.First().ToString());
            bool usedLast = false;

            for (int i = 1; i < first.Length; i++)
            {
                if (first[i] < last.First())
                {
                    output.Append(first[i]);
                }
                else
                {
                    output.Append(last.First());
                    usedLast = true;
                    break;
                }
            }

            if (!usedLast)
            {
                output.Append(last.First());
            }

            Console.WriteLine(output.ToString());

            //Console.WriteLine("DONE");
            //Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;

namespace CodeforcesTemplate
{
    public static class Permutation
    {
        private static bool Next(ref int[] arr)
        {
            int k, j, l;
            for (j = arr.Length - 2; (j >= 0) && (arr[j] >= arr[j + 1]); j--) { }
            if (j == -1)
            {
                arr = arr.OrderBy(c => c).ToArray();
                return false;
            }
            for (l = arr.Length - 1; (arr[j] >= arr[l]) && (l >= 0); l--) { }
            var tmp = arr[j];
            arr[j] = arr[l];
            arr[l] = tmp;
            for (k = j + 1, l = arr.Length - 1; k < l; k++, l--)
            {
                tmp = arr[k];
                arr[k] = arr[l];
                arr[l] = tmp;
            }
            return true;
        }
        public static IEnumerable<int[]> AllPermutations(int[] arr)
        {
            do yield return arr;
            while (Next(ref arr));
        }
    }

    class Program
    {
        private const string FILENAME = "distance4";

        private const string INPUT = FILENAME + ".in";

        private const string OUTPUT = FILENAME + ".out";

        private static Stopwatch _stopwatch = new Stopwatch();

        private static StreamReader _reader = null;
        private static StreamWriter _writer = null;

        private static string[] _curLine;
        private static int _curTokenIdx;

        private static char[] _whiteSpaces = new char[] { ' ', '\t', '\r', '\n' };

        private static string ReadNextToken()
        {
            if (_curTokenIdx >= _curLine.Length)
            {
                //Read next line
                string line = _reader.ReadLine();
                if (line != null)
                    _curLine = line.Split(_whiteSpaces, StringSplitOptions.RemoveEmptyEntries);
                else
                    _curLine = new string[] { };
                _curTokenIdx = 0;
            }

            if (_curTokenIdx >= _curLine.Length)
                return null;

            return _curLine[_curTokenIdx++];
        }

        private static int ReadNextInt()
        {
            return int.Parse(ReadNextToken());
        }

        private static void RunTimer()
        {
#if (DEBUG)

            _stopwatch.Start();

#endif
        }

        private static void Main(string[] args)
        {

#if (DEBUG)
            double before = GC.GetTotalMemory(false);
#endif

            string[] array = Console.ReadLine().Split(' ');

            string a = array[0];

            string b = array[1];

            string answer = "";

            char c = b[0];

            answer += a[0];

            for (int i = 1; i < a.Length; i++)
            {

                if (a[i] < c)
                {
                    answer += a[i];
                }

                else
                {
                    Console.WriteLine(answer + c);

                    return;
                }

            }

            Console.WriteLine(answer + c);

#if (DEBUG)
            _stopwatch.Stop();

            double after = GC.GetTotalMemory(false);

            double consumedInMegabytes = (after - before) / (1024 * 1024);

            Console.WriteLine($"Time elapsed: {_stopwatch.Elapsed}");

            Console.WriteLine($"Consumed memory (MB): {consumedInMegabytes}");

            Console.ReadKey();
#endif

        }

        private static int CountLeadZeros(string source)
        {
            int countZero = 0;

            for (int i = source.Length - 1; i >= 0; i--)
            {
                if (source[i] == '0')
                {
                    countZero++;
                }

                else
                {
                    break;
                }

            }

            return countZero;
        }

        private static string ReverseString(string source)
        {
            char[] reverseArray = source.ToCharArray();

            Array.Reverse(reverseArray);

            string reversedString = new string(reverseArray);

            return reversedString;
        }

        private static int[] CopyOfRange(int[] src, int start, int end)
        {
            int len = end - start;
            int[] dest = new int[len];
            Array.Copy(src, start, dest, 0, len);
            return dest;
        }

        private static string StreamReader()
        {

            if (_reader == null)
                _reader = new StreamReader(INPUT);
            string response = _reader.ReadLine();
            if (_reader.EndOfStream)
                _reader.Close();
            return response;

        }

        private static void StreamWriter(string text)
        {

            if (_writer == null)
                _writer = new StreamWriter(OUTPUT);
            _writer.WriteLine(text);

        }

        private static int BFS(int start, int end, int[,] arr)
        {
            Queue<KeyValuePair<int, int>> queue = new Queue<KeyValuePair<int, int>>();
            List<bool> visited = new List<bool>();
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                visited.Add(false);
            }

            queue.Enqueue(new KeyValuePair<int, int>(start, 0));
            KeyValuePair<int, int> node;
            int level = 0;
            bool flag = false;

            while (queue.Count != 0)
            {
                node = queue.Dequeue();
                if (node.Key == end)
                {
                    return node.Value;
                }
                flag = false;
                for (int i = 0; i < arr.GetLength(0); i++)
                {

                    if (arr[node.Key, i] == 1)
                    {
                        if (visited[i] == false)
                        {
                            if (!flag)
                            {
                                level = node.Value + 1;
                                flag = true;
                            }
                            queue.Enqueue(new KeyValuePair<int, int>(i, level));
                            visited[i] = true;
                        }
                    }
                }

            }
            return 0;

        }

        private static void Write(string source)
        {
            File.WriteAllText(OUTPUT, source);
        }

        private static string ReadString()
        {
            return File.ReadAllText(INPUT);
        }

        private static void WriteStringArray(string[] source)
        {
            File.WriteAllLines(OUTPUT, source);
        }

        private static string[] ReadStringArray()
        {
            return File.ReadAllLines(INPUT);
        }

        private static int[] GetIntArray()
        {
            return ReadString().Split(' ').Select(int.Parse).ToArray();
        }

        private static double[] GetDoubleArray()
        {
            return ReadString().Split(' ').Select(double.Parse).ToArray();
        }

        private static int[,] ReadINT2XArray(List<string> lines)
        {
            int[,] arr = new int[lines.Count, lines.Count];

            for (int i = 0; i < lines.Count; i++)
            {
                int[] row = lines[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();

                for (int j = 0; j < lines.Count; j++)
                {
                    arr[i, j] = row[j];
                }
            }

            return arr;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp12
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split();
            string res = a[0][0].ToString();
            for (int i = 1; i < a[0].Length; ++i)
            {
                if (a[0][i] < a[1][0]) res += a[0][i];
                else break;
            }
            res += a[1][0];
            Console.WriteLine(res);
        }
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Codeforces.NET
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] parts = line.Split(' ').ToArray();
            string first = parts[0];
            string second = parts[1];
            string solution = null;
            for (int i = 0; i < first.Length; i++)
            {
                for (int j = 0; j < second.Length; j++)
                {
                    string firstPrefix = first.Substring(0, i + 1);
                    string secondPrefix = second.Substring(0, j + 1);
                    string result = firstPrefix + secondPrefix;
                    if (solution == null)
                    {
                        solution = result;
                    }
                    else if (string.Compare(solution,result) > 0)
                    {
                        solution = result;
                    }
                }
            }

            Console.WriteLine(solution);
            Console.ReadLine();
        }
    }
}

using System;
using System.Linq;

namespace A_GenerateLogin
{
    class Program
    {
        static void Main(string[] args)
        {
            var names = Console.ReadLine().Split(' ').ToArray();
            var login = string.Join("", names[0].Take(1).Concat(names[0].Skip(1).TakeWhile(c => c < names[1][0])).Concat(new[] { names[1][0] }));
            Console.WriteLine(login);
        }
    }
}

using System;
using System.Text;
class GenerateLogin{
    static StringBuilder getLogin(string a, string b){
        int sa = 1, sb = 0;
        StringBuilder s = new StringBuilder("");
        s.Append(a[0]);
        while(sa<a.Length && sb<b.Length){
            if(b[sb] <= a[sa]){
                s.Append(b[sb]);
                return s;
            }
            else{
                s.Append(a[sa++]);
            }
        }
        s.Append(b[sb]);
        return s;
    }
    static void Main(string[] args){
        string[] str = Console.ReadLine().Trim().Split(' ');
        Console.Write(getLogin(str[0], str[1]));
    }
}

using System;

public static class Solve {
    public static void Main() {
        var s = Console.ReadLine().Split(' ');
        var lastLetter = s[1][0];
        Console.Write("{0}", s[0][0]);
        for (int i = 1; i < s[0].Length; i++) {
            if (s[0][i] >= lastLetter) break;
            Console.Write("{0}", s[0][i]);
        }
        Console.WriteLine("{0}", lastLetter);
    }
}

using System;
using System.Collections;
using System.Collections.Generic;

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜

namespace dd
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			var line = Console.ReadLine().Split(' ');
			string name = line[0] , surname = line[1];
			List<string> logins = new List<string>();
			for (int i = 0; i < name.Length; ++i)
			{
				string str = name.Substring(0, i + 1) + surname[0];
				logins.Add(str);
			}
			logins.Sort();
			Console.WriteLine(logins[0]);
		}
		class Reader
		{
			public static int NextInt()
			{
				int cnt = 0, sign = 1;
				char ch = Convert.ToChar(Console.Read());
				while (!(ch >= '0' && ch <= '9') && ch != '-')
					ch = Convert.ToChar(Console.Read());
				if (ch == '-')
				{
					sign = -1;
					ch = Convert.ToChar(Console.Read());
				}
				while (ch >= '0' && ch <= '9')
				{
					int t = Convert.ToInt32(ch);
					cnt = cnt * 10 + ch - '0';
					ch = Convert.ToChar(Console.Read());
				}
				return cnt * sign;
			}
			public static long NextLong()
			{
				long cnt = 0, sign = 1;
				char ch = Convert.ToChar(Console.Read());
				while (!(ch >= '0' && ch <= '9') && ch != '-')
					ch = Convert.ToChar(Console.Read());
				if (ch == '-')
				{
					sign = -1;
					ch = Convert.ToChar(Console.Read());
				}
				while (ch >= '0' && ch <= '9')
				{
					long t = Convert.ToInt32(ch);
					cnt = cnt * 10 + ch - '0';
					ch = Convert.ToChar(Console.Read());
				}
				return cnt * sign;
			}
		}
	}
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Codeforces
{
    class Program
    {
        static private string Compute(string s1, string s2)
        {
            List<string> usernames = new List<string>();
            for (int i = 1; i <= s1.Length; i++)
            {
                for (int j = 1; j <= s2.Length; j++)
                {
                    string un = s1.Substring(0, i) + s2.Substring(0, j);
                    usernames.Add(un);
                }
            }
            usernames.Sort();
            return usernames[0];
        }

        static public void Main()
        {
            string s1 = Console.ReadLine();
            while (s1 != null)
            {
                string[] ss = s1.Split(' ');
                string ans = Compute(ss[0], ss[1]);
                Console.WriteLine(ans);
                s1 = Console.ReadLine();
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace loginprefix
{
    class Program
    {
        static void Main(string[] args)
        {
            string name = Console.ReadLine();
            string[] ssize = name.Split(new char[0]);

            string fname = ssize[0];
            char[] char1 = fname.ToCharArray();

            string lname = ssize[1];
            char[] char2 = lname.ToCharArray();

            byte[] asciiBytes1 = Encoding.ASCII.GetBytes(fname);
            byte[] asciiBytes2 = Encoding.ASCII.GetBytes(lname);

            string login = fname.Substring(0,1);
            Boolean sec = false;
            for (int i = 1; i < asciiBytes1.Length; i++)
            {
                if (asciiBytes1[i] < asciiBytes2[0])
                    login += char1[i].ToString();
                else
                {
                    login += char2[0].ToString();
                    sec = true;
                    break;
                }

            }
            if(sec==false)
                login+= char2[0].ToString();

            Console.WriteLine(login);
          //  Console.ReadLine();

        }
    }
}

using System;

namespace CSharp
{
    public class _909A
    {
        public static void Main()
        {
            string[] tokens = Console.ReadLine().Split();

            string login = null;

            for (int l0 = 1; l0 <= tokens[0].Length; l0++)
            {
                for (int l1 = 1; l1 <= tokens[1].Length; l1++)
                {
                    string potentialLogin = tokens[0].Substring(0, l0) + tokens[1].Substring(0, l1);

                    if (login == null || string.Compare(potentialLogin, login) < 0)
                    {
                        login = potentialLogin;
                    }
                }
            }

            Console.WriteLine(login);
        }
    }
}

using System;
using System.Collections.Generic;

namespace UIConsole
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split();
            string a = line[0];
            string b = line[1];

            List<string> list = new List<string>();

            for (int i = 1; i <= a.Length; i++)
            {
                string temp = a.Substring(0, i);
                for (int j = 1; j <= b.Length; j++)
                {
                    string c = temp + b.Substring(0, j);
                    list.Add(c);
                }
            }
            list.Sort();
            Console.WriteLine(list[0]);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Генерация_логина
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            string name = input[0];
            string surname = input[1];

            string p1_login = "";
            List<string> logins = new List<string>();
            for (int i = 0; i < name.Length; i++)
            {
                string p2_login = "";
                p1_login += name[i];
                for (int j = 0; j < surname.Length; j++)
                {
                    p2_login += surname[j];
                    logins.Add(p1_login + p2_login);
                }
            }

            logins.Sort();
            Console.WriteLine(logins[0]);
        }
    }
}

using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            bool end = false;
            string[] input = Console.ReadLine().Split();
            string name = input[0];
            string surname = input[1];
            string result = Convert.ToString(name[0]);
            for (int i = 1; i < name.Length; i++)
            {
                if (name[i] < surname[0]) result += name[i];
                else
                {
                    result += surname[0];
                    end = true;
                    break;
                }
            }
            if (!end) result += surname[0];
            Console.WriteLine(result);
        }
    }
}

using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split();

        string res = s[0][0].ToString();
        for (int i = 1; i < s[0].Length; i++)
        {
            if (s[1][0] > s[0][i])
            {
                res += s[0][i];
            }
            else
            {
                break;
            }
        }
        res += s[1][0];
        Console.WriteLine(res);
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Generate_Login
{
    class Program
    {
        static void Main(string[] args)
        {

	string line = Console.ReadLine();

	string[] input = line.Split(' ');
            string firstName = input[0];
            string lastName = input[1];

	List<string> x = new List<string>();

            for (int i = 0; i < firstName.Length ; i++)
            {
                for (int j = 0; j < lastName.Length; j++)
                {
                	string str = firstName.Substring(0, i+1);
		string str1 = lastName.Substring(0, j+1);
		x.Add( str + str1 );
                }
            }

            string minimum = x[0];

            foreach(string str in x){
                 if(String.Compare(str, minimum) < 0) {
                 	minimum = str;
                 }
            }

	Console.WriteLine(minimum);
        }
    }

}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Codeforces
{
   class A
   {
      static void Main(string[] args)
      {
         string[] token = Console.ReadLine().Split();
         string A = token[0];
         string B = token[1];

         string ans = A[0] + "";

         for(int i=1;i<A.Length;i++){
            int b = B[0];
            int a = A[i];
            if(a<b){
              ans += A[i] + "";
            }else{
              break;
            }
         }
         ans +=  B[0] + "";
         Console.WriteLine(ans);
      }
   }

}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Generate_Login
{
    class Program
    {
        static void Main(string[] args)
        {

            string line = Console.ReadLine();

            string[] input = line.Split(' ');
            string firstName = input[0];
            string lastName = input[1];

            List<string> x = new List<string>();

            for (int i = 0; i < firstName.Length; i++)
            {
                for (int j = 0; j < lastName.Length; j++)
                {
                    string str = firstName.Substring(0, i + 1);
                    string str1 = lastName.Substring(0, j + 1);
                    x.Add(str + str1);
                }
            }

            string minimum = x[0];

            foreach (string str in x)
            {
                if (String.Compare(str, minimum) < 0)
                {
                    minimum = str;
                }
            }

            Console.WriteLine(minimum);
        }
    }

}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace elsof
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] nev = Console.ReadLine().Split(' ');
            string egyik = nev[0], masik = nev[1];
            StringBuilder sol = new StringBuilder();

            sol.Append(nev[0][0]);
            int i = 1;
            while (i < egyik.Length && egyik[i] < masik[0])
            {
                sol.Append(egyik[i]);
                i++;
            }
            sol.Append(masik[0]);
            Console.WriteLine(sol);
            Console.ReadLine();
        }
    }
}

// Problem: 909A - Generate Login
// Author: Gusztav Szmolik

using System;
using System.Text;

class GenerateLogin
    {
    static int Main ()
        {
        string[] words = ReadSplitLine (2);
        if (words == null)
            return -1;
        string firstName = words[0];
        byte fnLength = (byte)firstName.Length;
        if (fnLength > 10)
            return -1;
        foreach (char c in firstName)
            if (!Char.IsLower (c))
                return -1;
        string lastName = words[1];
        byte lnLength = (byte)lastName.Length;
        if (lnLength > 10)
            return -1;
        foreach (char c in lastName)
            if (!Char.IsLower (c))
                return -1;
        StringBuilder ans = new StringBuilder ();
        ans.Append (firstName[0]);
        for (byte i = 1; i < fnLength && firstName[i] < lastName[0]; i++)
            ans.Append (firstName[i]);
        ans.Append (lastName[0]);
        Console.WriteLine (ans);
        return 0;
        }

    static string[] ReadSplitLine (uint numWordNeed)
        {
        string line = Console.ReadLine ();
        if (line == null)
            return null;
        char[] delims = new char[2] {' ', '\t'};
        string[] words = line.Split (delims,StringSplitOptions.RemoveEmptyEntries);
        return (words.Length == numWordNeed ? words : null);
        }
    }

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string[] names = str.Split(' ');
            string name1 = names[0], name2 = names[1];
            string ans = "";
            ans += name1[0];
            for (int i = 1; i < name1.Length && name1[i] < name2[0]; i++)
                ans += name1[i];
            ans += name2[0];
            Console.WriteLine(ans);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

namespace CodeforcesTemplateClean
{
    class Program
    {

        public static bool IsPalindrome(BigInteger n)
        {
            BigInteger flip = 0;
            for (BigInteger i = n; i > 0; i /= 10)
            {
                flip = flip * 10 + (i % 10);
            }

            return n == flip;
        }

        static void Main(string[] args)
        {

            string[] array = Console.ReadLine().Split(' ');

            string name = array[0];

            char sName = array[1][0];

            int x = name.Length;

            for (int i = 1; i < name.Length; i++)
            {

               if (name[i] > sName)
                {
                    x = i;

                    break;
                }
            }

            StringBuilder answerBuilder = new StringBuilder();

            for (int i = 0; i < x; i++)
            {
                answerBuilder.Append(name[i]);
            }

            answerBuilder.Append(sName);

            Console.WriteLine(answerBuilder);

           // Console.ReadKey();
        }

    }

    public static class Permutation
    {
        private static bool Next(ref int[] arr)
        {
            int k, j, l;
            for (j = arr.Length - 2; (j >= 0) && (arr[j] >= arr[j + 1]); j--) { }
            if (j == -1)
            {
                arr = arr.OrderBy(c => c).ToArray();
                return false;
            }
            for (l = arr.Length - 1; (arr[j] >= arr[l]) && (l >= 0); l--) { }
            var tmp = arr[j];
            arr[j] = arr[l];
            arr[l] = tmp;
            for (k = j + 1, l = arr.Length - 1; k < l; k++, l--)
            {
                tmp = arr[k];
                arr[k] = arr[l];
                arr[l] = tmp;
            }
            return true;
        }
        public static IEnumerable<int[]> AllPermutations(int[] arr)
        {
            do yield return arr;
            while (Next(ref arr));
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

namespace CodeforcesTemplateClean
{
    class Program
    {

        public static bool IsPalindrome(BigInteger n)
        {
            BigInteger flip = 0;
            for (BigInteger i = n; i > 0; i /= 10)
            {
                flip = flip * 10 + (i % 10);
            }

            return n == flip;
        }

        static void Main(string[] args)
        {

            string[] arr = Console.ReadLine().Split(' ');

            StringBuilder pref = new StringBuilder();

            for (int i = 0; i < arr[0].Length; i++)
            {

                pref.Append(arr[0][i]);

                if (arr[0][i] == 'a')
                {
                    pref.Append(arr[1][0]);
                    break;
                }
            }

            Console.WriteLine(pref.ToString());

           // Console.ReadKey();
        }

    }

    public static class Permutation
    {
        private static bool Next(ref int[] arr)
        {
            int k, j, l;
            for (j = arr.Length - 2; (j >= 0) && (arr[j] >= arr[j + 1]); j--) { }
            if (j == -1)
            {
                arr = arr.OrderBy(c => c).ToArray();
                return false;
            }
            for (l = arr.Length - 1; (arr[j] >= arr[l]) && (l >= 0); l--) { }
            var tmp = arr[j];
            arr[j] = arr[l];
            arr[l] = tmp;
            for (k = j + 1, l = arr.Length - 1; k < l; k++, l--)
            {
                tmp = arr[k];
                arr[k] = arr[l];
                arr[l] = tmp;
            }
            return true;
        }
        public static IEnumerable<int[]> AllPermutations(int[] arr)
        {
            do yield return arr;
            while (Next(ref arr));
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

namespace CodeforcesTemplateClean
{
    class Program
    {

        public static bool IsPalindrome(BigInteger n)
        {
            BigInteger flip = 0;
            for (BigInteger i = n; i > 0; i /= 10)
            {
                flip = flip * 10 + (i % 10);
            }

            return n == flip;
        }

        static void Main(string[] args)
        {

            string[] arr = Console.ReadLine().Split(' ');

            StringBuilder pref = new StringBuilder();

            for (int i = 0; i < arr[0].Length; i++)
            {

                pref.Append(arr[0][i]);

                if (arr[0][i] == 'a')
                {
                    break;
                }
            }

            pref.Append(arr[1][0]);

            Console.WriteLine(pref.ToString());

           // Console.ReadKey();
        }

    }

    public static class Permutation
    {
        private static bool Next(ref int[] arr)
        {
            int k, j, l;
            for (j = arr.Length - 2; (j >= 0) && (arr[j] >= arr[j + 1]); j--) { }
            if (j == -1)
            {
                arr = arr.OrderBy(c => c).ToArray();
                return false;
            }
            for (l = arr.Length - 1; (arr[j] >= arr[l]) && (l >= 0); l--) { }
            var tmp = arr[j];
            arr[j] = arr[l];
            arr[l] = tmp;
            for (k = j + 1, l = arr.Length - 1; k < l; k++, l--)
            {
                tmp = arr[k];
                arr[k] = arr[l];
                arr[l] = tmp;
            }
            return true;
        }
        public static IEnumerable<int[]> AllPermutations(int[] arr)
        {
            do yield return arr;
            while (Next(ref arr));
        }
    }
}

using System;

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');

            string fName = str[0];
            string lName = str[1];

            string res = string.Empty;

            // calc
            int indexOf = -1;
            for (int i = 1; i < fName.Length; i++)
            {
                if (fName[i] < lName[0])
                {
                    indexOf = i;
                }
            }

            if (indexOf == -1)
            {
                res += fName[0];
            }
            else
            {
                res += fName.Substring(0, indexOf + 1);
            }

            res += lName[0];

            Console.WriteLine(res);

        }
    }
}

using System;

public static class Solve {
    public static void Main() {
        var s = Console.ReadLine().Split(' ');
        var lastLetter = s[1][0];
        Console.Write("{0}", s[0][0]);
        for (int i = 1; i < s[0].Length; i++) {
            if (s[0][i] > lastLetter) break;
            Console.Write("{0}", s[0][i]);
        }
        Console.WriteLine("{0}", lastLetter);
    }
}

using System;

namespace CSharp
{
    public class _909A
    {
        public static void Main()
        {
            string[] tokens = Console.ReadLine().Split();

            string login = null;

            for (int l0 = 1; l0 <= tokens[0].Length; l0++)
            {
                for (int l1 = 1; l1 < tokens[1].Length; l1++)
                {
                    string potentialLogin = tokens[0].Substring(0, l0) + tokens[1].Substring(0, l1);

                    if (login == null || string.Compare(potentialLogin, login) < 0)
                    {
                        login = potentialLogin;
                    }
                }
            }

            Console.WriteLine(login);
        }
    }
}

using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split();

        string res = s[0][0].ToString();
        for (int i = 1; i < s[0].Length; i++)
        {
            if (res[res.Length - 1] > s[0][i])
            {
                res += s[0][i];
            }
            else
            {
                break;
            }
        }
        res += s[1][0];
        Console.WriteLine(res);
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string[] names = str.Split(' ');
            string name1 = names[0], name2 = names[1];
            string ans = "";
            for (int i = 0; i < name1.Length && name1[i] < name2[0]; i++)
                ans += name1[i];
            ans += name2[0];
            Console.WriteLine(ans);
        }
    }
}