#include<bits/stdc++.h>
#define ld long double
#define int long long
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
using namespace std;
void solve(){
string s,t;
cin>>s>>t;
map<char,vector<int>>mp;
int n=s.length(),m=t.length();
for (int i=0;i<m;i++) {
mp[t[i]].push_back(i);
}
int x=0,inds=-1,indt=-1;
for (int i=0;i<n;i++) {
if (!mp[s[i]].empty()) {
int l=0,r=mp[s[i]].size()-1;
vector<int>v=mp[s[i]];
while (l<=r) {
int mid=(l+r)/2;
int sz=m-v[mid];
if (sz+i>=3&&(i!=0&&sz!=2)) {
indt=v[mid];
l=mid+1;
}else r=mid-1;
}
if (indt!=-1) {
inds=i;
break;
}
}
}
if (inds==-1||indt==-1) {
cout<<"-1\n";
return;
}
string ans=s.substr(0, inds);
ans+=t.substr(indt, m);
cout<<ans<<"\n";
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t=1;
//cin>>t;
while(t--){
solve();
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBsZCBsb25nIGRvdWJsZQojZGVmaW5lIGludCBsb25nIGxvbmcKI2RlZmluZSBhbGwodikgdi5iZWdpbigpLHYuZW5kKCkKI2RlZmluZSBhbGxyKHYpIHYucmJlZ2luKCksdi5yZW5kKCkKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdm9pZCBzb2x2ZSgpewogICAgc3RyaW5nIHMsdDsKICAgIGNpbj4+cz4+dDsKICAgIG1hcDxjaGFyLHZlY3RvcjxpbnQ+Pm1wOwogICAgaW50IG49cy5sZW5ndGgoKSxtPXQubGVuZ3RoKCk7CiAgICAgZm9yIChpbnQgaT0wO2k8bTtpKyspIHsKICAgICAgICAgbXBbdFtpXV0ucHVzaF9iYWNrKGkpOwogICAgIH0KICAgIGludCB4PTAsaW5kcz0tMSxpbmR0PS0xOwogICAgZm9yIChpbnQgaT0wO2k8bjtpKyspIHsKICAgICAgICAgIGlmICghbXBbc1tpXV0uZW1wdHkoKSkgewogICAgICAgICAgICAgICBpbnQgbD0wLHI9bXBbc1tpXV0uc2l6ZSgpLTE7CiAgICAgICAgICAgICAgICB2ZWN0b3I8aW50PnY9bXBbc1tpXV07CgogICAgICAgICAgICAgIHdoaWxlIChsPD1yKSB7CiAgICAgICAgICAgICAgICAgIGludCBtaWQ9KGwrcikvMjsKICAgICAgICAgICAgICAgICAgIGludCBzej1tLXZbbWlkXTsKICAgICAgICAgICAgICAgICAgaWYgKHN6K2k+PTMmJihpIT0wJiZzeiE9MikpIHsKICAgICAgICAgICAgICAgICAgICAgIGluZHQ9dlttaWRdOwogICAgICAgICAgICAgICAgICAgICAgbD1taWQrMTsKICAgICAgICAgICAgICAgICAgfWVsc2Ugcj1taWQtMTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKGluZHQhPS0xKSB7CiAgICAgICAgICAgICAgICAgIGluZHM9aTsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgfQogICAgaWYgKGluZHM9PS0xfHxpbmR0PT0tMSkgewogICAgICAgIGNvdXQ8PCItMVxuIjsKICAgICAgICByZXR1cm47CiAgICB9CiAgICBzdHJpbmcgYW5zPXMuc3Vic3RyKDAsIGluZHMpOwogICAgYW5zKz10LnN1YnN0cihpbmR0LCBtKTsKICAgICBjb3V0PDxhbnM8PCJcbiI7Cn0KaW50MzJfdCBtYWluKCkgewogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7CiAgICBjaW4udGllKG51bGxwdHIpOwogICAgY291dC50aWUobnVsbHB0cik7CiAgICBpbnQgdD0xOwogICAgLy9jaW4+PnQ7CiAgICB3aGlsZSh0LS0pewogICAgICAgIHNvbHZlKCk7CiAgICB9Cn0=