Program Xaukytu;
Var S1,S2,S3:String;
F:Array[0..100,0..100] Of Integer;
Function Max(a,b:integer):integer;
Begin
If a>b then max:=a else max:=b;
End;
Procedure Init;
Var i,j:integer;
Begin
Readln(s1);
Readln(s2);
For i:=0 to length(s1) do
F[i,0]:=0;
For j:=0 to length(s2) do
F[0,j]:=0;
For i:=1 to length(s1) do
For j:=1 to length(s2) do
If S1[i]=S2[j] then
F[i,j]:=F[i-1,j-1]+1
Else
F[i,j]:=Max(F[i-1,j],F[i,j-1]);
S3:='';
i:=Length(s1);
j:=Length(s2);
Repeat
If F[i,j]=F[i-1,j-1]+1 then begin S3:=S3+S1[i];dec(i);dec(j);end
Else
If F[i,j]=F[i-1,j] then dec(i) else dec(j);
Until (i=0) or (j=0);
writeln(s3);
End;
BEGIN
Init;
readln
end.