#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define TEST int t;cin>>t;while(t--)
#define rep(i,n) for(int i=0;i<n;i++)
#define fr first
#define sc second
#define popcount __builtin_popcountll
#define IOS ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
const ll mod=1000000007;
typedef vector<int,int> p1;
typedef vector<ll,ll> p2;
int main()
{
IOS;
//TEST{
string a,b,res="-1";
cin>>a>>b;
int mi=min(a.length(),b.length());
rep(i,mi-1){
string str=a.substr(0,i+1);
string str1=a.substr(i+1,a.length());
string sb=b.substr(b.length()-i-1,b.length());
string sb1=b.substr(0,b.length()-i-1);
//cout<<str<<" "<<str1<<" "<<sb<<" "<<sb1<<endl;
if(string(sb+str)==string(sb1+str1)){res=sb1+str; break;}
}
if(a==b)res=a;
cout<<res;
cout<<endl;
//}
return 0;
}
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define TEST int t;cin>>t;while(t--)
#define rep(i,n) for(int i=0;i<n;i++)
#define fr first
#define sc second
#define popcount __builtin_popcountll
#define IOS ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
const ll mod=1000000007;
typedef vector<int,int> p1;
typedef vector<ll,ll> p2;
int main()
{
IOS;
//TEST{
string a,b,res="-1";
cin>>a>>b;
int mi=min(a.length(),b.length());
rep(i,mi-1){
string str=a.substr(0,i+1);
string str1=a.substr(i+1,a.length());
string sb=b.substr(b.length()-i-1,b.length());
string sb1=b.substr(0,b.length()-i-1);
//cout<<str<<" "<<str1<<" "<<sb<<" "<<sb1<<endl;
if(string(sb+str)==string(sb1+str1)){res=sb1+str; break;}
}
if(a==b)res=a;
cout<<res;
cout<<endl;
//}
return 0;
}
Copy