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>
#include<string>
using namespace std;
static const int MAX=3000;
int dp[MAX+1][MAX+1];
int main(void){
	string s,t;
		cin >> s >> t;
	int ss=s.size();
	int ts=t.size();
	for(int i=0;i<ss;i++){
		for(int j=0;j<ts;j++){
			if(s[i]==t[j])
				dp[i+1][j+1]=dp[i][j]+1;
			else
				dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
		}
	}
	
	int i=ss;
	int j=ts;
	string ans="";
	while(dp[i][j]>0){
		if(s[i-1]==t[j-1]){
			ans=s[i-1]+ans;
			i--;j--;
		}
		else if(dp[i][j-1]==dp[i-1][j-1])
			i--;
		else
			j--;
	}
	cout << ans << endl;
	return 0;
}