Problem: You are given strings s and t. Find one longest string that is a subsequence of both s and t.

Constraints

* s and t are strings consisting of lowercase English letters.
* 1 \leq |s|, |t| \leq 3000

Input

Input is given from Standard Input in the following format:


s
t


Output

Print one longest string that is a subsequence of both s and t. If there are multiple such strings, any of them will be accepted.

Examples

Input

axyb
abyxb


Output

axb


Input

aa
xayaz


Output

aa


Input

a
z


Output




Input

abracadabra
avadakedavra


Output

aaadara

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll Dp[3030][3030];

int main()
{
    string s,t; cin>>s>>t;

    ll n = s.size();
    ll m = t.size();

    for(ll i=n-1;i>=0;i--)
        for(ll j=m-1;j>=0;j--)
            Dp[i][j] = max( max ( Dp[i][j+1] , Dp[i+1][j] ) , (ll)(s[i]==t[j]) + Dp[i+1][j+1] );

    for(ll i=0,j=0;i<n&&j<m;)
        if(Dp[i][j]==Dp[i][j+1])
            j++;
        else if(Dp[i][j]==Dp[i+1][j])
            i++;
        else
        {
            if(s[i]==t[j])  cout<<s[i];
            i++;j++;
        }

}