#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
const double eps=1e-7,PI=3.1415926;
const int N=1e6+10;
using namespace std;
int n,q,m,k,x,y,a[N],mx=-1,mn=1e9,sum;
string str1,str2,s1,s2;
map < int , int > mp;
vector < int > vec;
int main(){
cin>>s1>>s2;
n=s1.size();
m=s2.size();
if (s1==s2)return cout<<s1<<endl,0;
if ((n+m)%2)return cout<<-1<<endl,0;
for (int i=0;i<n;i++){
if (i+1>(n+m)/2||(n+m)/2-(i+1)>m)continue;
str1="",str2="";
for (int j=0;j<(n+m)/2-(i+1);j++)str1+=s2[j];
for (int j=0;j<=i;j++)str1+=s1[j];
for (int j=(n+m)/2-(i+1);j<m;j++)str2+=s2[j];
for (int j=i+1;j<n;j++)str2+=s1[j];
if (str1==str2)return cout<<str1<<endl,0;
}
if (m>=(n+m)/2){
str1="",str2="";
for (int i=0;i<(n+m)/2;i++)str1+=s2[i];
for (int i=(n+m)/2;i<m;i++)str2+=s2[i];
for (int i=0;i<n;i++)str2+=s1[i];
if (str1==str2)return cout<<str1<<endl,0;
}
cout<<-1<<endl;
return 0;
}
Copy