s = gets.chomp
t = gets.chomp

result = ""

trace = [[1] * (s.size + 1)]
dp = [0] * (s.size + 1)
dp_new = [0] * (s.size + 1)

1.upto(t.size) do |i|
  e_t = t[i - 1]
  tr = [1]

  1.upto(s.size) do |j|
    j_prev = j - 1
    dp_new[j] = if e_t == s[j_prev]
                  tr << 2
                  dp[j_prev] + 1
                else
                  if dp[j] < dp_new[j_prev]
                    tr << 1
                    dp_new[j_prev]
                  else
                    tr << 3
                    dp[j]
                  end
                end
  end

  trace << tr
  dp = dp_new
end

i = t.size
j = s.size
while 0 < i && 0 < j
  if trace[i][j] == 1
    j -= 1
  elsif trace[i][j] == 2
    i -= 1
    j -= 1
    result = s[j] + result
  else
    i -= 1
  end
end

puts result
