#include <bits/stdc++.h>
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define pii pair <int,int>
#define pll pair <ll,ll>
#define INF 1000000000
#define mod 1000000007
#define size(a) ((int)(a.size()))
using namespace std;
void solv()
{
string s,ss;
cin>>s>>ss;
if(s==ss)
{
for(int i=0,j=size(s)/2;j<size(s);i++,j++)
{
if(s[i]!=s[j])
{
cout<<-1<<endl;
return;
}
}
cout<<s<<endl;
return;
}
int is=(size(s)-1)/2,js=size(s)/2, iss=(size(ss)-1)/2,jss=size(ss)/2;
while(iss>0 && is>0 && js<size(s) && jss<size(ss) && s[is]==ss[iss] && s[js]==ss[jss]) is--,iss--,js++,jss++;
for(int i=0,j=js;j<size(s);j++,i++)
{
if(s[i]!=s[j])
{
cout<<-1<<endl;
return;
}
}
for(int i=0,j=jss;j<size(ss);j++,i++)
{
if(ss[i]!=ss[j])
{
cout<<-1<<endl;
return;
}
}
for(int i=jss;i<size(ss);i++) cout<<ss[i];
for(int i=is+1;i<size(s);i++) cout<<s[i];
cout<<endl;
}
int main()
{
quick
int TT=1; // cin>>TT;
while(TT--) solv();
return 0;
}
Copy