import std.algorithm, std.stdio, std.string;

string longer(ref in string x, ref in string y) {
  if (x.length < y.length) return y;
  return x;
}

void main() {
  const s = readln.chomp;
  const t = readln.chomp;
  
  string[][] dp;
  dp.length = s.length+1;
  foreach (ref x; dp) x.length = t.length+1;
  
  foreach (si; 1..s.length+1) foreach (ti; 1..t.length+1) {
    if (s[si-1] == t[ti-1]) {
      dp[si][ti] = dp[si-1][ti-1] ~ t[ti-1];
    } else {
      dp[si][ti] = longer(dp[si-1][ti], dp[si][ti-1]);
    }
  }
  dp[$-1][$-1].writeln;
}