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 <iostream>
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
string ans[2][3010];
string a,b;
string comp(string l,string r){
	if(l.size()>r.size())return l;
	return r;
}
int main(){
	cin>>a>>b;
	for(int i=1;i<=a.size();i++){
		for(int j=1;j<=b.size();j++){
			ans[i%2][j]=comp(ans[(i-1)%2][j],ans[i%2][j-1]);
			if(a[i-1]==b[j-1])ans[i%2][j]=comp(ans[i%2][j],ans[(i-1)%2][j-1]+a[i-1]);
		}
	}
	cout<<ans[a.size()%2][b.size()]<<endl;
}