#include<bits/stdc++.h>
using namespace std ;
string a , b , ra , rb ;
int l ;
int zab[2000000+5] , zarb[2000000+5] , zrab[2000000+5] ;
int llll = 0 ;
void Zcalc(string s , int *z) {
memset( z , 0 , sizeof z ) ;
int L = 0, R = 0;
int n = s.size() ;
for (int i = 1; i < n ; i++) {
if (i > R) {
L = R = i;
while (R < n && s[R-L] == s[R]) R++;
z[i] = R-L;
R--;
} else {
int k = i-L;
if (z[k] < R-i+1) z[i] = z[k];
else {
L = i;
while (R < n && s[R-L] == s[R]) R++;
z[i] = R-L;
R--;
}
}
}
}
int main() {
while( getline(cin , a ) ) {
getline(cin , b ) ;
if( (a.size() == 1 && b.size() ==1)||(a.size() != b.size()) ){
cout << -1 << " " << -1 << endl ;
continue ;
}
ra = a ;
reverse(ra.begin(),ra.end()) ;
rb = b ;
reverse(rb.begin(),rb.end()) ;
l= a.size()+b.size()+1 ;
Zcalc(b+'\x7F'+a,zab);
Zcalc(a+'\x7F'+rb,zarb);
Zcalc(ra+'\x7F'+b,zrab);
int ansI=-1 , ansJ=10000000 ;
for( int i = b.size()+1, j = 0 ; i < l ; i++ , j++ ) {
int I = j ;
int J = j+zab[i] ;
int leftLen = j ;
int checkLeftLen = zarb[a.size()+1] ;
if( checkLeftLen >= leftLen ) {
int rightLen = a.size()+b.size()-i-zab[i]+1 ;
int checkRightLen = zrab[ a.size() + 1 + zab[i] ];
if( checkRightLen >= rightLen ){
if( I > ansI )ansI = I , ansJ = J ;
else if( I == ansI ){
if( J < ansJ ){
ansJ = J ;
}
}
}
}
}
if( ansI+1 == ansJ ) ansJ-- ;
if( ansI == -1 )cout << -1 << " " << -1 << "\n" ;
else cout << ansI-1 << " " << ansJ << "\n" ;
}
return 0 ;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZCA7CnN0cmluZyBhICwgYiAsIHJhICwgcmIgOwppbnQgbCA7CmludCB6YWJbMjAwMDAwMCs1XSAsIHphcmJbMjAwMDAwMCs1XSAsIHpyYWJbMjAwMDAwMCs1XSA7CmludCBsbGxsID0gMCA7CnZvaWQgWmNhbGMoc3RyaW5nIHMgLCBpbnQgKnopIHsKICBtZW1zZXQoIHogLCAwICwgc2l6ZW9mIHogKSA7CiAgaW50IEwgPSAwLCBSID0gMDsKICBpbnQgbiA9IHMuc2l6ZSgpIDsKICBmb3IgKGludCBpID0gMTsgaSA8IG4gOyBpKyspIHsKICAgIGlmIChpID4gUikgewogICAgICBMID0gUiA9IGk7CiAgICAgIHdoaWxlIChSIDwgbiAmJiBzW1ItTF0gPT0gc1tSXSkgUisrOwogICAgICB6W2ldID0gUi1MOwogICAgICBSLS07CiAgICB9IGVsc2UgewogICAgICBpbnQgayA9IGktTDsKICAgICAgaWYgKHpba10gPCBSLWkrMSkgeltpXSA9IHpba107CiAgICAgIGVsc2UgewogICAgICAgIEwgPSBpOwogICAgICAgIHdoaWxlIChSIDwgbiAmJiBzW1ItTF0gPT0gc1tSXSkgUisrOwogICAgICAgIHpbaV0gPSBSLUw7CiAgICAgICAgUi0tOwogICAgICB9CiAgICB9CiAgfQp9CgppbnQgbWFpbigpIHsKCiAgd2hpbGUoIGdldGxpbmUoY2luICwgYSApICkgewoKICAgIGdldGxpbmUoY2luICwgYiApIDsKICAgIGlmKCAoYS5zaXplKCkgPT0gMSAmJiBiLnNpemUoKSA9PTEpfHwoYS5zaXplKCkgIT0gYi5zaXplKCkpICl7CiAgICAgIGNvdXQgPDwgLTEgPDwgIiAiIDw8IC0xIDw8IGVuZGwgOwogICAgICBjb250aW51ZSA7CiAgICB9CiAgICByYSA9IGEgOwogICAgcmV2ZXJzZShyYS5iZWdpbigpLHJhLmVuZCgpKSA7CiAgICByYiA9IGIgOwogICAgcmV2ZXJzZShyYi5iZWdpbigpLHJiLmVuZCgpKSA7CgogICAgbD0gYS5zaXplKCkrYi5zaXplKCkrMSA7CgogICAgWmNhbGMoYisnXHg3RicrYSx6YWIpOwogICAgWmNhbGMoYSsnXHg3RicrcmIsemFyYik7CiAgICBaY2FsYyhyYSsnXHg3RicrYix6cmFiKTsKCiAgICBpbnQgYW5zST0tMSAsIGFuc0o9MTAwMDAwMDAgOwoKICAgIGZvciggaW50IGkgPSBiLnNpemUoKSsxLCBqID0gMCAgOyBpIDwgbCA7IGkrKyAsIGorKyApIHsKICAgICAgaW50IEkgPSBqIDsKICAgICAgaW50IEogPSBqK3phYltpXSA7CiAgICAgIGludCBsZWZ0TGVuID0gaiA7CiAgICAgIGludCBjaGVja0xlZnRMZW4gPSB6YXJiW2Euc2l6ZSgpKzFdIDsKICAgICAgaWYoIGNoZWNrTGVmdExlbiA+PSBsZWZ0TGVuICkgewogICAgICAgIGludCByaWdodExlbiA9IGEuc2l6ZSgpK2Iuc2l6ZSgpLWktemFiW2ldKzEgOwogICAgICAgIGludCBjaGVja1JpZ2h0TGVuID0genJhYlsgYS5zaXplKCkgKyAxICsgemFiW2ldIF07CiAgICAgICAgaWYoIGNoZWNrUmlnaHRMZW4gPj0gcmlnaHRMZW4gKXsKICAgICAgICAgIGlmKCBJID4gYW5zSSApYW5zSSA9IEkgLCBhbnNKID0gSiA7CiAgICAgICAgICBlbHNlIGlmKCBJID09IGFuc0kgKXsKICAgICAgICAgICAgaWYoIEogPCBhbnNKICl7CiAgICAgICAgICAgICAgYW5zSiA9IEogOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBpZiggYW5zSSsxID09IGFuc0ogKSBhbnNKLS0gOwogICAgaWYoIGFuc0kgPT0gLTEgKWNvdXQgPDwgLTEgPDwgIiAiIDw8IC0xIDw8ICJcbiIgOwogICAgZWxzZSBjb3V0IDw8IGFuc0ktMSA8PCAiICIgPDwgYW5zSiA8PCAiXG4iIDsKCiAgfQogIHJldHVybiAwIDsKfQoKCg==