#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-O2")
using namespace std;
using ll = long long;
using ld = long double;
int dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
int dy[] = {0, 0, 1, -1, -1, 1, -1, 1};
const int N = 2E5 + 5, M = 2E6 + 10, MOD = 1E9 + 7, OO = 0x3f3f3f3f;;
int n, m, x;
string s, t;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif /*ONLINE_JUDGE*/
cin >> s >> t;
n = s.size(), m = t.size();
for (int i = 0; i < n/2; ++i) {
if(s.substr(0, i+1) == s.substr(n-i-1, i+1)){
x = n - 2 * s.substr(0, i+1).size();
if((m - x) & 1) continue;
if(t.substr(0, (m-x)/2) == t.substr(m-(m-x)/2, (m-x)/2+1)){
if(x == 0 || s.substr(i+1, x) == t.substr((m-x)/2, x))
return cout << t.substr(0, (m-x)/2) + s.substr(0, i+1), 0;
}
}
}
cout << -1;
return 0;
}
Copy