S = gets.chomp.split('')
T = gets.chomp.split('')

dp = Array.new(S.size + 1) { Array.new(T.size + 1, 0) }

S.each_with_index do |s, s0|
  s1 = s0 + 1

  T.each_with_index do |t, t0|
    t1 = t0 + 1

    dp[s1][t1] = dp[s0][t0] + 1 if s == t
    dp[s1][t1] = dp[s1][t0]     if dp[s1][t1] < dp[s1][t0]
    dp[s1][t1] = dp[s0][t1]     if dp[s1][t1] < dp[s0][t1]
  end
end

i = dp[S.size][T.size]
s = S.size
t = T.size
a = ''

while i > 0
  case
  when dp[s - 1][t] == i then s -= 1
  when dp[s][t - 1] == i then t -= 1
  else
    a.insert(0, S[s - 1])
    i -= 1
    s -= 1
    t -= 1
  end
end

print a