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 PYTHON):

Solution:
s, t = raw_input().strip(), raw_input().strip()
n, m = len(s), len(t)

dp = [[0 for i in xrange(m)] for j in xrange(n)]

dp[0][0] = int(s[0] == t[0])

i = 0
for j in xrange(1, m):
    if s[i] == t[j]: dp[i][j] = 1
    else: dp[i][j] = dp[i][j - 1]

j = 0
for i in xrange(1, n):
    if s[i] == t[j]: dp[i][j] = 1
    else: dp[i][j] = dp[i - 1][j]

for i in xrange(1, n):
    for j in xrange(1, m):
        if i == 0 and j == 0: continue
        if s[i] == t[j]:
            dp[i][j] = dp[i - 1][j - 1] + 1
        else:
            dp[i][j] = max(dp[i][j - 1], dp[i - 1][j])

c = [0 for i in xrange(dp[n - 1][m - 1])]

st = len(c) - 1
i, j = n - 1, m - 1
while st >= 0:
    if s[i] == t[j]:
        c[st] = s[i]
        i -= 1
        j -= 1
        st -= 1
    else:
        if i >= 1 and j >= 1:
            if dp[i][j - 1] < dp[i - 1][j]: i -= 1
            else: j -= 1
        else:
            if i >= 1: i -= 1
            else: j -= 1

print ''.join(c)