#include<bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#define all(x) x.begin(),x.end()
#define sc(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define LL long long
#define LD long double
#define pb push_back
#define F first
#define S second
const double PI=3.1415926535897932384626433;
const int KL=1e6;
const LL MOD=1e9+7;
using namespace std;
/*
typedef complex<double> point;
#define x real()
#define y imag()
*/
LL q,x,y,z,n,m,a[KL],mn=1e9,mx=-1e9,ans;
vector <LL> vec;
set <LL> s;
map <LL,LL> mp;
int main()
{
string s,t;
cin>>s>>t;
if(s==t){
cout<<s<<endl;
return 0;
}
n=s.size();
m=t.size();
bool flag=false;
string ret;
for(int i=0;i<n;i++){
if(i+1<=n-(i+1)){
bool ok=true;
int en=n-1,r=i;
while(r>=0){
if(s[r]!=s[en]){
ok=false;
break;
}
r--;
en--;
}
if(!ok)continue;
int sz=t.size()+n-2*(i+1);
if(sz%2!=0 || n-2*(i+1)>sz/2)continue;
int rem=sz/2-(n-2*(i+1));
int st=0;
for(int j=m-1-rem+1;j<m;j++){
if(t[j]!=t[st]){ok=false;break;}
st++;
}
for(int j=i+1;j<n-(i+1);j++){
if(s[j]!=t[st]){ok=false;break;}
st++;
}
if(!ok)continue;
///cout<<st<<endl;
for(int j=0;j<st;j++)cout<<t[j];
for(int j=n-(i+1);j<n;j++)cout<<s[j];cout<<endl;
return 0;
}
}
swap(s,t);
for(int i=0;i<n;i++){
if(i+1<=n-(i+1)){
bool ok=true;
int en=n-1,r=i;
while(r>=0){
if(s[r]!=s[en]){
ok=false;
break;
}
r--;
en--;
}
if(!ok)continue;
int sz=t.size()+n-2*(i+1);
if(sz%2!=0 || n-2*(i+1)>sz/2)continue;
int rem=sz/2-(n-2*(i+1));
int st=0;
for(int j=m-1-rem+1;j<m;j++){
if(t[j]!=t[st]){ok=false;break;}
st++;
}
for(int j=i+1;j<n-(i+1);j++){
if(s[j]!=t[st]){ok=false;break;}
st++;
}
if(!ok)continue;
///cout<<st<<endl;
for(int j=0;j<st;j++)cout<<t[j];
for(int j=n-(i+1);j<n;j++)cout<<s[j];cout<<endl;
return 0;
}
}
cout<<-1<<endl;
return 0;
}
Copy