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 main() {
  string s, t; cin >> s >> t;
  vector<string> dp(s.size(), "");

  for (int i = 0; i < t.size(); i++)
  {
    char c = t[i];
    string tmp = "";
    vector<string> nextdp(dp);
    for (int j = 0; j < s.size(); j++)
    {
      if (s[j] == c && dp[j].size() < tmp.size() + 1) {
        nextdp[j] = tmp;
        nextdp[j].push_back(c);
      }
      if (tmp.size() < dp[j].size()) tmp = dp[j];
    }
    dp = nextdp;
  }

  string ans = "";
  for (auto& s : dp)
  {
    if (ans.size() < s.size()) ans = s;
  }

  cout << ans << endl;
}