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 f[3001][3001];
char a[3001],b[3001];
void ff(int i,int j)
{
	if(i==0||j==0)
		return;
	if(a[i-1]==b[j-1])
		ff(i-1,j-1);
	else if(f[i][j-1]>=f[i-1][j])
		ff(i,j-1);
	else
		ff(i-1,j);
	if(a[i-1]==b[j-1])
		printf("%c",a[i-1]);
}
int main()
{
	int i,j,l1,l2;
	scanf("%s",a);
	scanf("%s",b);
	l1=strlen(a);
	l2=strlen(b);
	for(i=1;i<=l1;i++)
	{
		for(j=1;j<=l2;j++)
		{
			if(a[i-1]!=b[j-1])
				f[i][j]=max(f[i-1][j],f[i][j-1]);
			else
				f[i][j]=f[i-1][j-1]+1;
		}
	}
	ff(l1,l2);
	return 0;
}