#include <bits/stdc++.h>
#define ll long long
#define R return
#define pb push_back
#define F first
#define S second
#define B break
#define C continue
#define SI size()
using namespace std;
string s,t,r,rr,x,y;
int main()
{
cin>>s>>t;
ll n=s.SI,m=t.SI;
ll h=0;
for(ll i=0;i<s.SI;i++){
r=s.substr(0,i+1);
rr=t.substr(m-i-1,i+1);
x=rr+s.substr(i+1,n-i-1);
y=t.substr(0,m-i-1)+r;
if(x==y){
h=1;B;
}
}
if(h==1)cout<<x;
else cout<<"-1";
return 0;
}