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;
#define rep(i, a, b) for (int i = a; i <= b; ++i)
const int N = 3001;

string s, t, ans; int f[N][N];

int main() {
	ios::sync_with_stdio(false);
	cin >> s >> t; int n = s.size(), m = t.size();
	rep(i, 1, n) rep(j, 1, m) {
		if (s[i - 1] == t[j - 1]) f[i][j] = f[i - 1][j - 1] + 1;
		f[i][j] = max(f[i][j], max(f[i][j - 1], f[i - 1][j]));
	} 
	while (n && m) {
		if (s[n - 1] == t[m - 1])
			ans += s[n - 1], n--, m--;
		else if(f[n][m - 1] > f[n - 1][m])
			m--;
		else
			n--;
	}
	reverse(ans.begin(), ans.end());
	
	cout << ans << '\n';
	return 0;
}