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:
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

const int N = 3e3 + 5;
int n, m, dp[N][N];
string s, t;

void solve(int i, int j) {
	if (!~i || !~j)
		return;
	if (s[i] == t[j]) {
		solve(i - 1, j - 1);
		cout << s[i];
		return;
	}
	dp[i + 1][j] > dp[i][j + 1]? solve(i, j - 1): solve(i - 1, j);
}

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);

	cin >> s >> t;
	n = s.size(), m = t.size();
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			dp[i + 1][j + 1] = (s[i] == t[j]? dp[i][j] + 1: max(dp[i][j + 1], dp[i + 1][j]));
	solve(n - 1, m - 1);

	return 0;
}