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 l[3002][3002];
int main()
{
 string s1,s2;
 cin>>s1>>s2;
 int m=s1.size(),n=s2.size();
 
 for(int i=0;i<=m;++i)
 for(int j=0;j<=n;++j)
 {    if(i==0||j==0)
      l[i][j]=0;
      else if(s1[i-1]==s2[j-1])
            l[i][j]=1+l[i-1][j-1];
       else l[i][j]=max(l[i-1][j],l[i][j-1]) ;    
 } int i=m,j=n;
 int k=l[i][j];char arr[k];
 while(i!=0&&j!=0)
 {  
    
    if(l[i-1][j]==l[i][j])
       i=i-1;
       else if (l[i][j-1]==l[i][j]) 
	   j=j-1;
	   else {arr[k-1]=s1[i-1];k--;i=i-1;j=j-1;}
	
 }
 	
 for(int i=0;i<l[m][n];++i)
  cout<<arr[i];	
	
	
	
	
}