eolymp
bolt
Try our new interface for solving problems

LCS-2

Two strings are given. Find their longest common subsequence.

Input

Two strings consisting of small Latin letters. The length of each string is no more than 1000.

Output

Print the longest common subsequence of two strings.

Time limit 1 second
Memory limit 128 MiB
Input example #1
abacaba
dacabc
Output example #1
acab
Input example #2
sislksh
lkshsis
Output example #2
lksh