#include<stdio.h>
#include<string.h>
#define N 100100
void getnext(int next[],char s[]) {
int k=-1,j=0;
next[0]=-1;
while(s[j]!=0) {
if(k==-1||s[j]==s[k]) {
j++;k++;
if(s[j]!=s[k])
next[j]=k;
else
next[j]=next[k];
}
else
k=next[k];
}
}
int kmpa(char t[],char T[],int next[]) {
int len ,i,j;
len=strlen(T);
j=0;i=0;
while(i!=len) {
if(t[j]==T[i])
i++,j++;
else {
j=next[j];
if(j==-1)
j=0,i++;
}
}
return j;
}
int main() {
int len1,len2;
int next1[N],next2[N];
char s1[N],s2[N];
while(scanf("%s%s",s1,s2)!=EOF) {
getnext(next1,s1);
len1=kmpa(s1,s2,next1);
getnext(next2,s2);
len2=kmpa(s2,s1,next2);
if(len1==len2) {
if(strcmp(s1,s2)>0)
printf("%s%s
",s2,s1+len1);
else
printf("%s%s
",s1,s2+len2);
}
if(len1>len2)
printf("%s%s
",s2,s1+len1);
else
if(len1<len2)
printf("%s%s
",s1,s2+len2);
}
return 0;
}