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

void main() {
  const s = readln.chomp;
  const t = readln.chomp;
  
  size_t[][] dp;
  dp.length = s.length+1;
  foreach (ref x; dp) x.length = t.length+1;
  
  foreach (i; 1..s.length+1) foreach (j; 1..t.length+1) {
    if (s[i-1] == t[j-1]) {
      dp[i][j] = dp[i-1][j-1] + 1;
    } else {
      dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    }
  }
  
  string ans;
  size_t x = t.length, y = s.length;
  while (x > 0 && y > 0) {
    if (dp[y][x] == dp[y-1][x]) {
      --y;
    } else if (dp[y][x] == dp[y][x-1]) {
      --x;
    } else {
      --x;
      --y;
      ans ~= s[y];
    }
  }
  ans.retro.to!string.writeln;
}