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 f(i,a,b) for(int i = a; i < b; i++)
#define MAX 1000000010
using namespace std;
typedef long long int ll;
int dp[3010][3010];
int main(){
	int n,m,x,ans=0;
	string s,t,res="";
	cin>>s>>t;
	n=s.size(), m=t.size();
	f(i,0,n+1){
		f(j,0,m+1){
			if(i==0 || j==0) continue;
			if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
			else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
		}
	}
	int a=n,b=m;
	while(dp[a][b]>0){
		int x=dp[a][b];
		if(x==dp[a-1][b]) a--;
		else if(x==dp[a][b-1])b--;
		else res+=s[a-1], a--, b--;
	}
	reverse(res.begin(),res.end());
	cout<<res;
}