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

void main() {
	auto s = readln.chomp.dup;
	auto t = readln.chomp.dup;

	if (t.length < s.length) {
		swap(s, t);
	}

	auto dp0 = new char[][s.length + 1];
	auto dp1 = new char[][s.length + 1];
	foreach (ref e;dp0) {
		e = new char[0];
	}
	dp1[0] = new char[0];

	foreach (te;t) {
		foreach (size_t i, se;s) {
			if (te == se) {
				dp1[i + 1] = dp0[i];
				dp1[i + 1] ~= te;
			} else if (dp0[i + 1].length >= dp1[i].length) {
				dp1[i + 1] = dp0[i + 1];
			} else {
				dp1[i + 1] = dp1[i];
			}
		}
		swap(dp0, dp1);
	}

	writeln(dp0[s.length]);
}
