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 n,m;
int f[3005][3005];
char a[3005],b[3005];

int main()
{
	scanf("%s",a+1);
	scanf("%s",b+1);
	n = strlen(a+1);
	m = strlen(b+1);
	for(int i=n;i>=1;i--)
		for(int j=m;j>=1;j--)
			if(a[i]==b[j])
				f[i][j] = f[i+1][j+1]+1;
			else
				f[i][j] = max(f[i][j+1],f[i+1][j]);
	int p1=1,p2=1;
	while(p1<=n && p2<=m)
	{
		if(a[p1]==b[p2])
		{
			cout<<a[p1];
			p1++;
			p2++;
		}
		else if(f[p1][p2]==f[p1+1][p2])
			p1++;
		else
			p2++;
	}
	cout<<endl;
	
	return 0;
}