/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
Scanner in
= new Scanner
(System.
in);
a = in.nextLine();
b = in.nextLine();
char ch;
for(int i=0; i<a.length(); i++){
ch = a.charAt(i);
a2
+=Character.
toLowerCase(ch
); //Избавляемся от всех знаков кроме букв и понижаем регистр. }
}
for(int i=0; i<b.length(); i++){
ch = b.charAt(i);
b2
+=Character.
toLowerCase(ch
); //Избавляемся от всех знаков кроме букв и понижаем регистр. }
}
if(a2==b2){
System.
out.
println(a2
);//Если строки равны, сразу возвращаем значение одной из них. } else {
for(int i=0; i<a2.length(); i++){ //Сравниваем символы в строках.
for(int j=0; j<b2.length(); j++){
if(a2.charAt(i)==b2.charAt(j)){
c+=a2.charAt(i);
for(int k=i+1, t=j+1; (k<a2.length())&&(t<b2.length()); k++, t++){
if(a2.charAt(k)==b2.charAt(t)){
c+=a2.charAt(k);//Те, которые совпали, записываем в новую строку.
} else {
break;
}
}
c+=' ';
}
}
}
int r=0, max=0; //В получившейся строке считаем, сколько букв в самом большом слове.
for(int i=0; i<c.length(); i++){
if(c.charAt(i)!=' '){
r++;
} else {
if(r>max){
max=r;
}
r=0;
}
}
for(int i=0; i<c.length(); i++){ //Ищем слова такой же длины и записываем их в строку для вывода черех пробел.
if(c.charAt(i)!=' '){
c2+=c.charAt(i);
} else {
if(c2.length()==max){
for(int j=0; j<c2.length(); j++){
maxstr+=c2.charAt(j);
}
maxstr+=' ';
}
}
}
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2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