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 N1, N2;
int f[3003][3003];
char s[3003], t[3003];

int main() {
	cin >> s >> t;
	N1 = strlen(s), N2 = strlen(t);
	for(int i = 1; i <= N1; ++i)
		for(int j = 1; j <= N2; ++j) {
			f[i][j] = max(f[i - 1][j], f[i][j - 1]);
			if(s[i - 1] == t[j - 1])
				f[i][j] = max(f[i][j], f[i - 1][j - 1] + 1);
		}
	string Ans;
	int x = N1, y = N2;
	while(x > 0 && y > 0) {
		if(f[x][y] == f[x - 1][y]) {
			--x;
		} else if(f[x][y] == f[x][y - 1]) {
			--y;
		} else {
			Ans += s[x - 1];
			--x, --y;
		}
	}
	reverse(Ans.begin(), Ans.end());
	cout << Ans << endl;
	return 0;
}