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

Solution:
#import numpy as np
a = input()
b = input()
dp = [[0] * (len(b) + 1)  for i in range(len(a) + 1)]

for x in range(len(a)):
	for y in range(len(b)):
		if a[x] == b[y]:
			dp[x + 1][y + 1] = dp[x][y] + 1
		else:
			dp[x + 1][y + 1] = max(dp[x + 1][y], dp[x][y + 1])
		
x, y = len(a) - 1, len(b) - 1
s = ''
while (x >= 0 and y >= 0):
	if a[x] == b[y]:
		s = a[x] + s
		x -= 1
		y -= 1
	elif dp[x][y + 1] > dp[x + 1][y]:
		x -= 1
	else:
		y -= 1
		
print(s)