# https://atcoder.jp/contests/dp/tasks/dp_f

S = gets.chomp
T = gets.chomp

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

S.each_char.with_index do |s, s0|
  dps0 = dp[s0]
  dps1 = dp[s0 + 1]

  T.each_char.with_index do |t, t0|
    t1 = t0 + 1

    dps1[t1] = dps0[t0] + 1 if s == t
    dps1[t1] = dps1[t0]     if dps1[t1] < dps1[t0]
    dps1[t1] = dps0[t1]     if dps1[t1] < dps0[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
