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


namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;

        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }

            var res = line[index];
            index++;
            return res;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public ulong NextUlong()
        {
            return ulong.Parse(Next());
        }

        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }

        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }

        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    struct MyStruct
    {
        public long N;
        public int Cnt;
    }

    class Program
    {
        private string S, T;
        void Scan()
        {
            var sc = new Scanner();
            S = sc.Next();
            T = sc.Next();
        }

        public void Solve()
        {
            Scan();
            var dp = new int[S.Length + 1, T.Length + 1];

            for (int i = 1; i <= S.Length; i++)
            {
                for (int j = 1; j <= T.Length; j++)
                {
                    if (S[i - 1] == T[j - 1])
                    {
                        dp[i, j] = dp[i - 1, j - 1] + 1;
                    }
                    else
                    {
                        dp[i, j] = Math.Max(dp[i - 1, j], dp[i, j - 1]);
                    }
                }
            }

            var ans = new char[dp[S.Length, T.Length]];
            int x = S.Length;
            int y = T.Length;


            int p = ans.Length - 1;
            while (true)
            {
                if (x == 0 || y == 0) break;
                if (S[x - 1] == T[y - 1])
                {
                    ans[p] = S[x - 1];
                    x--;
                    y--;
                    p--;
                }
                else
                {
                    if (dp[x - 1, y] > dp[x, y - 1])
                    {
                        x--;

                    }
                    else
                    {
                        y--;
                    }
                }
            }
            Console.WriteLine(new string(ans));
        }




        static void Main() => new Program().Solve();
    }


}

Measured memory_bytes: 46048