/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
axyb
abyxb
---+/
/+---test
aa
xayaz
---+/
/+---test
a
z
---+/
/+---test
abracadabra
avadakedavra
---+/

void main(string[] args) {
  const S = readln.chomp;
  const T = readln.chomp;

  auto dp = new string[][](S.length, T.length);
  foreach (si, s; S) foreach (ti, t; T) {
    string p1;
    if (s == t) {
      p1 = (si && ti? dp[si-1][ti-1]: "") ~ s;
    }
    const p2 = si? dp[si-1][ti]: "";
    const p3 = ti? dp[si][ti-1]: "";

    const l = max(p1.length, p2.length, p3.length);
    if (p1.length == l) dp[si][ti] = p1;
    if (p2.length == l) dp[si][ti] = p2;
    if (p3.length == l) dp[si][ti] = p3;
  }
  dp[$-1][$-1].writeln;
}
