'use strict';
console.log(function(args){
  const tmp = args.trim().split('\n');
  const s = tmp[0], t = tmp[1];
  const sl = s.length, tl = t.length;
  let dp = [];
  for ( let i = 0; i <= sl; i++ ) {
    dp.push(Array(tl+1).fill([0,'']) );
  }
  for ( let i = 0; i < sl; i++ ) {
    for ( let j = 0; j < tl; j++ ) {
      if ( t[j] === s[i] ) { dp[i+1][j+1][0] = dp[i][j][0]+1; dp[i+1][j+1][1] = dp[i][j][1] + s[i]; }
      else {
        if ( dp[i+1][j+1][0] < dp[i+1][j][0] ) { dp[i+1][j+1][0] = dp[i+1][j][0]; dp[i+1][j+1][1] = dp[i+1][j][1]; }
        if ( dp[i+1][j+1][0] < dp[i][j+1][0] ) { dp[i+1][j+1][0] = dp[i][j+1][0]; dp[i+1][j+1][1] = dp[i][j+1][1]; }
      }
    }
  }
  return dp[sl][tl][1];
}(require('fs').readFileSync('/dev/stdin', 'utf8')));
