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>
using namespace std;
int t[4000][4000]; 
int LCS(char a[],char b[],int n,int m)
{
string str;
for(int i=1;i<=m;i++)
{
for(int j=1;j<=n;j++)
{
if(b[i-1]==a[j-1])
{
t[i][j]=1+t[i-1][j-1];
}
else{
t[i][j]=max(t[i-1][j],t[i][j-1]);
}
}
}
return t[m][n];
}
int main()
{
memset(t,0,sizeof(t));
char a[3000],b[3000];
cin>>a;
cin>>b;
LCS(a,b,strlen(a),strlen(b));
int i=strlen(b);
int j=strlen(a);
string str;
while(i>0 && j>0)
{
if(a[j-1]==b[i-1])
{
str=str+a[j-1];
i=i-1;
j=j-1;
}else
{
if(t[i][j-1]>t[i-1][j])
{
j=j-1;
}else{
i=i-1;
}
}
}
reverse(str.begin(),str.end());
cout<<str<<endl;
return 0;
}