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=raw_input().strip()
t=raw_input().strip()
n=len(s)
m=len(t)
z=[[0]*(m+1) for _ in xrange(n+1)]
for i in xrange(n):
    for j in xrange(m):
        if s[i]==t[j]:
            z[i+1][j+1]=z[i][j]+1
        else:
            z[i+1][j+1]=max(z[i+1][j],z[i][j+1])
i=n-1
j=m-1
a=[]
while i>=0 and j>=0:
    if s[i]==t[j]:
        a.append(s[i])
        i-=1
        j-=1
    elif z[i][j+1]>z[i+1][j]:
        i-=1
    else:
        j-=1
print ''.join(a[::-1])