#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++){
str1+=s1[i];
string tmp="",tmp2=s2;
bool b=1;
while(tmp.size()+str1.size()<(n+m)/2){
if (tmp2.empty()){
b=0;
break;
}
tmp.pb(tmp2.back());
tmp2.pop_back();
}
reverse(all(tmp));
tmp+=str1;
if (b==0)continue;
string ch=tmp2;
ch+=s1.substr(i+1,n-i-1);
if (tmp==ch)return cout<<tmp<<endl,0;
}
cout<<-1<<endl;
return 0;
}
Copy