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<cstdio>
#include<cstring>
const int N=3003;
char a[N],b[N];int la,lb,dp[N][N],g[N][N];
void Out(int i,int j){
	if(!i||!j)return;
	switch(g[i][j]){
	  case 0:Out(i-1,j-1);putchar(a[i]);return;
	  case 1:Out(i,j-1);return;
	  case 2:Out(i-1,j);return;
	}
}
signed main(){
	scanf("%s%s",a+1,b+1);la=strlen(a+1),lb=strlen(b+1);
	for(int i=1;i<=la;i++)
	  for(int j=1;j<=lb;j++){
		if(a[i]==b[j])
		  dp[i][j]=dp[i-1][j-1]+1,g[i][j]=0;
		else if(dp[i][j-1]>dp[i-1][j])
		  dp[i][j]=dp[i][j-1],g[i][j]=1;
		else
		  dp[i][j]=dp[i-1][j],g[i][j]=2;
	  }
	Out(la,lb);
	return 0;
}