#include <bits/stdc++.h>
using namespace std ;
const int MAX = 2e5 + 10 ;
int arr[MAX] ;
int n ;
string s , t ;
string s2 , t2 ;
int main()
{
ios_base::sync_with_stdio(0) ;
cin.tie(0) ;
cin>>s ;
cin>>t ;
int n = s.size() , m = t.size() ;
for(int i = 0 ; i < n ; ++i)
{
s2 = "" , t2 = "" ;
int x = n - i , y = m + i ;
if(y < x || (y - x) % 2 != 0)
continue ;
int diff = (y - x) / 2 ;
for(int j = 0 ; j < diff ; ++j)
s2.push_back(t[m-diff+j]) ;
for(int j = i ; j < n ; ++j)
s2.push_back(s[j]) ;
for(int j = 0 ; j < m-diff ; ++j)
t2.push_back(t[j]) ;
for(int j = 0 ; j < i ; ++j)
t2.push_back(s[j]) ;
if(s2 == t2)
return cout<<s2<<"\n" , 0 ;
}
return cout<<-1<<"\n" , 0 ;
}
Copy