#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
const int inf = 1e9;
const ll infll = 1e18;
const int M = 1e9 + 7;
const int N = 4e5;
int main(){
string s, t;
cin >> s >> t;
int n = s.size(), m = t.size();
if((n+m)%2){
puts("-1");
return 0;
}
string ss[2] = {"",""}, tt[2] = {"",""};
int midn = (n+m)/2;
for (int i = 0; i < n; ++i){
int prefLen = i+1;
int lenNow = n - prefLen;
int suffLen = midn - lenNow;
// cout << prefLen << " " << suffLen << endl;
if(suffLen < 0 || suffLen > m) continue;
ss[0] = s.substr(0, prefLen);
ss[1] = s.substr(prefLen);
tt[0] = t.substr(0, m-suffLen);
tt[1] = t.substr(m-suffLen);
// cout << ss[0] << " " << ss[1] << endl;
if((tt[1] + ss[1]) == (tt[0] + ss[0])){
cout << (tt[1] + ss[1]) << endl;
return 0;
}
}
puts("-1");
}
Copy