import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy



sys.setrecursionlimit(10**7)

inf=10**20

mod=10**9+7

dd=[(-1,0),(0,1),(1,0),(0,-1)]

ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]



def LI(): return [int(x) for x in sys.stdin.readline().split()]

def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]

def I(): return int(sys.stdin.readline())

def LS(): return sys.stdin.readline().split()

def S(): return eval(input())



def main():

  s=S()

  t=S()



  lns=len(s)

  lnt=len(t)



  dp=[[0 for _ in range(lns+1)]for _ in range(lnt+1)]

  for i in range(lnt):

    for j in range(lns):

      if t[i]==s[j]:

        dp[i+1][j+1]=dp[i][j]+1

      else:

        dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])



  ans=''

  i=lnt

  j=lns

  while dp[i][j]!=0:

    if dp[i][j]==dp[i-1][j]:

      i-=1

    elif dp[i][j]==dp[i][j-1]:

      j-=1

    elif dp[i][j]==dp[i-1][j-1]:

      i-=1

      j-=1

    elif dp[i][j]==dp[i-1][j-1]+1:

      ans=t[i-1]+ans

      i-=1

      j-=1



  return ans



# main()

print((main()))

import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy



sys.setrecursionlimit(10**7)

inf=10**20

mod=10**9+7

dd=[(-1,0),(0,1),(1,0),(0,-1)]

ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]



def LI(): return [int(x) for x in sys.stdin.readline().split()]

def LF(): return [float(x) for x in sys.stdin.readline().split()]

def I(): return int(sys.stdin.readline())

def F(): return float(sys.stdin.readline())

def LS(): return sys.stdin.readline().split()

def S(): return eval(input())



def main():

  s=S()

  t=S()



  ns=len(s)

  nt=len(t)



  dp=[[0]*(ns+1) for _ in range(nt+1)]



  for i in range(nt):

    for j in range(ns):

      if t[i]==s[j]:

        dp[i+1][j+1]=dp[i][j]+1

      else:

        dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])



  ans=[]

  i=nt

  j=ns

  while dp[i][j]!=0:

    if dp[i][j]==dp[i-1][j]:

      i-=1

    elif dp[i][j]==dp[i][j-1]:

      j-=1

    elif dp[i][j]==dp[i-1][j-1]:

      i-=1

      j-=1

    elif dp[i][j]==dp[i-1][j-1]+1:

      i-=1

      j-=1

      ans.append(t[i])



  ans.reverse()

  return ''.join(ans)



# main()

print((main()))

import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI():
    return [int(x) for x in sys.stdin.readline().split()]


def LI_():
    return [int(x) - 1 for x in sys.stdin.readline().split()]


def I():
    return int(sys.stdin.readline())


def LS():
    return sys.stdin.readline().split()


def S():
    return eval(input())


def main():
    s = S()
    t = S()
    lns = len(s)
    lnt = len(t)
    dp = [[0 for _ in range(lns + 1)] for _ in range(lnt + 1)]
    for i in range(lnt):
        for j in range(lns):
            if t[i] == s[j]:
                dp[i + 1][j + 1] = dp[i][j] + 1
            else:
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j])
    ans = ""
    i = lnt
    j = lns
    while dp[i][j] != 0:
        if dp[i][j] == dp[i - 1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j - 1]:
            j -= 1
        elif dp[i][j] == dp[i - 1][j - 1]:
            i -= 1
            j -= 1
        elif dp[i][j] == dp[i - 1][j - 1] + 1:
            ans = t[i - 1] + ans
            i -= 1
            j -= 1
    return ans


# main()
print((main()))

import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI():
    return [int(x) for x in sys.stdin.readline().split()]


def LF():
    return [float(x) for x in sys.stdin.readline().split()]


def I():
    return int(sys.stdin.readline())


def F():
    return float(sys.stdin.readline())


def LS():
    return sys.stdin.readline().split()


def S():
    return eval(input())


def main():
    s = S()
    t = S()
    ns = len(s)
    nt = len(t)
    dp = [[0] * (ns + 1) for _ in range(nt + 1)]
    for i in range(nt):
        for j in range(ns):
            if t[i] == s[j]:
                dp[i + 1][j + 1] = dp[i][j] + 1
            else:
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j])
    ans = []
    i = nt
    j = ns
    while dp[i][j] != 0:
        if dp[i][j] == dp[i - 1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j - 1]:
            j -= 1
        elif dp[i][j] == dp[i - 1][j - 1]:
            i -= 1
            j -= 1
        elif dp[i][j] == dp[i - 1][j - 1] + 1:
            i -= 1
            j -= 1
            ans.append(t[i])
    ans.reverse()
    return "".join(ans)


# main()
print((main()))

-import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy +import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy -def LI_(): -    return [int(x) - 1 for x in sys.stdin.readline().split()] +def LF(): +    return [float(x) for x in sys.stdin.readline().split()] + + +def F(): +    return float(sys.stdin.readline()) -    lns = len(s) -    lnt = len(t) -    dp = [[0 for _ in range(lns + 1)] for _ in range(lnt + 1)] -    for i in range(lnt): -        for j in range(lns): +    ns = len(s) +    nt = len(t) +    dp = [[0] * (ns + 1) for _ in range(nt + 1)] +    for i in range(nt): +        for j in range(ns): -    ans = "" -    i = lnt -    j = lns +    ans = [] +    i = nt +    j = ns -            ans = t[i - 1] + ans -    return ans +            ans.append(t[i]) +    ans.reverse() +    return "".join(ans)