#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
typedef long long ll;
int main(){
string a,b;
cin>>a>>b;
string a1="";
for(int i=0;i<int(a.size());i++){
string tst1="",tst2="";
int j = int(b.size()) - (i+(int(b.size())-int(a.size())));
if(j>=int(b.size()) || j<0)continue;
for(int k=j;k<int(b.size());k++)tst1+=b[k];
for(int k=i;k<int(a.size());k++)tst1+=a[k];
for(int k=0;k<j;k++)tst2+=b[k];
for(int k=0;k<i;k++)tst2+=a[k];
if(tst1 == tst2){
cout<<tst1;
return 0;
}
}
cout<<-1;
return 0;
}
Copy