#include<iostream>
using namespace std;
int main(){
char A[500], B[500];
int len, lenend, lent;
int i, j, k, it, jt, iin, jin;
bool in;
while(cin >> A >> B){
lent = 0; len = 0;
for(i = 0; A[i] != '\0'; i++);
for(j = 0; B[j] != '\0'; j++);
A[i] = 1, B[j] = 2;
in = false;
if(i >= j){
k = j;
for(j = 0; j<k && k - j > len; j++){
it = 0; jt = j;
while(it <= i && jt <= k){
if(B[jt] == A[it]){
if(!in)
iin = it;
lent++; jt++; in = true;}
else{
if(in){
lent > len ? len = lent, lenend = jt - 1, lent = 0: lent = 0;
in = false; jt = j; it = iin + 1;continue;}
}
it++;
}
}
if(!len)
cout << "E" << endl;
else{
for(i = lenend - len + 1; i <= lenend; i++)
cout << B[i];
cout << endl;}
}
else{
k = i;
for(i = 0; i<k && k - i > len; i++){
jt = 0; it = i;
while(jt <= j && it <= k){
if(A[it] == B[jt]){
if(!in)
jin = jt;
lent++; it++; in = true;}
else{
if(in){
lent > len ? len = lent, lenend = it - 1, lent = 0: lent = 0;
in = false; it = i; jt = jin + 1;continue;}
}
jt++;
}
}
if(!len)
cout << "E" << endl;
else{
for(i = lenend - len + 1; i <= lenend; i++)
cout << A[i];
cout << endl;}
}
}
}