#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define Ma7moud_7amdy \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define Open_Sesame Open()
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define watch(x) cout << #x << " = " << x << endl;
#define endl "\n"
#define INF 0x3f3f3f3f3f3f3f3fLL
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
typedef long long ll;
typedef unsigned long long ull;
void Open()
{
#ifndef ONLINE_JUDGE
freopen("standard.in", "r", stdin);
freopen("standard.out", "w", stdout);
#else
//freopen("colors.in", "r", stdin);
//freopen("standard.out", "w", stdout);
#endif
}
const ll mod = int(1e9 + 7), N = 2e5 + 5, oo = int(1e9);
//"The secret of getting ahead is getting started". Mark Twain
//if you get WR, don't try to debug the code too much: think about another idea;
//don't be afraid of letters,letter G doesn't mean the problem is hard;
//don't stuck in one problem after you gets alot WR ,just jump to the next one
int main()
{
Ma7moud_7amdy;
// Open_Sesame;
string a, b;
cin >> a >> b;
int sz = a.size() + b.size();
if (sz & 1)return cout << -1 << endl, 0;
sz >>= 1;
for (int i = max(0, (int)a.size() - sz); i < a.size(); ++i) {
int prefix_length = i;
int suffix_length = max(0, (int)(sz - (a.size() - i)));
if (suffix_length > b.size())break;
string A = b.substr(b.size() - suffix_length) + a.substr(i);
string B = b.substr(0, b.size() - suffix_length) + a.substr(0, i);
if (A == B) {
cout << A << endl;
return 0;
}
}
cout << -1 << endl;
}
//"There's a way to do it better - find it". Thomas A. Edison
Copy