//* Problem  : 1217 - Advanced Fruits
//* Contest  : acm.tju.edu.cn
//* Origin   : University of Ulm Local Contest 1999
//* Type     : Solution
//* Date     : 2008.06.06
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 8.0

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <iostream>
using namespace std;
#define int64 long long
#define INF 1000000000
#define EPS 1E-8

#define ALL(a) a.begin(), a.end()
#define PB(a, v) a.push_back(v)
#define MP(a,b) make_pair(a, b)
#define FOR(i, n) for (int i = 0; i < (n); i++)

char s1[128], s2[128];

char lcs[128];

int len;

int b[128][128], c[128][128];


int buildLCS(char *X, int n, char *Y, int m)
{
	int i, j;
	for (i = 1; i <= n; i++)
		c[i][0] = 0;
	for (j = 0; j <= m; j++)
		c[0][j] = 0;
	
	for (i = 1; i <= n; i++)
		for (j = 1; j <= m; j++)
		{
			if (X[i - 1] == Y[j - 1]) 
			{
				c[i][j] = c[i - 1][j - 1] + 1;
				b[i][j] = 1;
			}
			else if (c[i - 1][j] >= c[i][j - 1]) 
			{
				c[i][j] = c[i - 1][j];
				b[i][j] = 2;
			}
			else
			{
				c[i][j] = c[i][j - 1];
				b[i][j] = 3;
			}
		}
	return c[n][m];
}

void printLCS(int i, int j) 
{
	if (!i || !j) return;
	
	if (b[i][j] == 1) 
	{
		printLCS(i - 1, j - 1);
		lcs[len++] = s1[i-1];
	}
	else if (b[i][j] == 2)
		printLCS(i - 1,j);
	else
		printLCS(i,j - 1);
}

void split(string &s, char *s1, char *s2)
{
	string res = "";
	for (int i = 0; i < s.length(); i++)
	{
		char *p1 = strchr(s1, s[i]);
		char *p2 = strchr(s2, s[i]);
		for (char *t = s1; t < p1; t++)
			res.push_back(*t);
		for (char *t = s2; t < p2; t++)
			res.push_back(*t);
		res.push_back(s[i]);
		s1 = p1 + 1; s2 = p2 + 1;
	}
	while (*s1) res.push_back(*s1++);
	while (*s2) res.push_back(*s2++);
	s = res;
}

int main()
{
#ifdef _DEBUG
	freopen("1166.in", "r", stdin);
#endif
	int n, m, it = 0;
	while (scanf("%s%s", s1, s2) == 2)
	{
		n = strlen(s1); m = strlen(s2);
		buildLCS(s1, n, s2, m);
		len = 0; printLCS(n, m); lcs[len] = 0;
		string l(lcs);
		split(l, s1, s2);
		printf("%s\n", l.c_str());
	}
	return 0;
}
