'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;
  const dp = [Array(tl+1).fill('')];
  for ( let i = 0; i < sl; i++ ) {
    dp.push(['']);
    for ( let j = 0; j < tl; j++ ) {
      dp[i+1].push('');
      if ( t[j] === s[i] ) dp[i+1][j+1] = dp[i][j] + s[i];
      if ( dp[i+1][j+1].length < dp[i+1][j].length ) dp[i+1][j+1] = dp[i+1][j];
      if ( dp[i+1][j+1].length < dp[i][j+1].length ) dp[i+1][j+1] = dp[i][j+1];
    }
  }
  return dp[sl][tl];
}(require('fs').readFileSync('/dev/stdin', 'utf8')));
