/*
        HELLO WORLD
        -----------
        SHUBHAM
        -----------
        :) CODING
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ff                                         first
#define ss                                         second
#define pb                                         push_back
//#define int                                        long long
#define mp                                         make_pair
#define pii                                        pair<int,int>
#define vi                                         vector<int>
#define mii                                        map<int,int>
#define umii                                       unordered_map<int,int>
#define pqb                                        priority_queue<int>
#define pqs                                        priority_queue<int,vi,greater<int>>
#define setbits(x)                                 __builtin_popcountll(x)
#define zerobits(x)                                 __builtin_ctzll(x)
#define mod                                        1000000007
#define inf                                        1e18
#define ps(x,y)                                    fixed<<setprecision(y)<<x
#define mk(arr,n,type)                             type *arr=new type[n]
#define test(t)                                    int t;cin>>t;while(t--)
#define rep(i,n)                                   for(int i=0;i<n;i++)
#define rep1(i,n)                                  for(int i=1;i<=n;i++)
#define fio                                        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SIZE                                       100001
#define all(x)                                     (x).begin(),(x).end()
#define sclk()                                     auto start_time = Clock::now()
#define eclk()                                     auto end_time = Clock::now();  cout << "\nTime Taken : " << chrono::duration_cast<chrono::milliseconds>(end_time    - start_time).count() << " ms"
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef std::chrono::high_resolution_clock Clock;

int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) { return b?gcd(b,a%b):a;}

void f_io()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif // ONLINE_JUDGE
}
int dp[3000][3000];
string s,t;
int solve(int st1,int st2)
{
    if(st1==s.size() || st2==t.size())
        return 0;
    if(dp[st1][st2]==-1)
    {
            if(s[st1]==t[st2])
            {
                dp[st1][st2]=1+solve(st1+1,st2+1);
            }
            else
            {
                dp[st1][st2]=max(solve(st1+1,st2),solve(st1,st2+1));
            }
    }
    return dp[st1][st2];
}
int32_t main()
{
    {
     cin>>s;
        cin>>t;
        memset(dp,-1,sizeof(dp));
        solve(0,0);
        string ans="";
        int i=0,j=0;
        while(i<s.size() && j<t.size())
        {
            if(s[i]==t[j])
            {
                ans+=s[i];
                i+=1;
                j+=1;
            }
            else if(dp[i+1][j]>dp[i][j+1])
            {
                i+=1;
            }
            else
                j+=1;
        }
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 35712