#include <iostream>
#include <string>
using namespace std;
void str_Changed(string &st1, string &st2){
int str_len1 = st1.size();
int str_len2 = st2.size();
if(str_len1 < str_len2){
string temp = st1;
st1 = st2;
st2 = temp;
}
}
int main(){
string str1;
string str2;
while(cin >> str1 >> str2){
str_Changed(str1,str2);//确保str1比str2长
int len1 = str1.size();
int len2 = str2.size();
int cnt = 0;
int maxm = 0;
int index = 0;
for(int i = 0; i < len2; i++){
int temp = i;
cnt = 0;
for(int j = 0; j < len1; j++){
if(str1[j] == str2[temp]){
cnt++;
temp++;
}
else if(cnt > maxm){
maxm = cnt;
index = i;
cnt = 0;
temp = i;
}
else if(cnt <= maxm){
cnt = 0;
temp = i;
}
}
}
for(int i = index; i < index + maxm; i++){
cout << str2[i];
}
}
}