#include <bits/stdc++.h>   using namespace std;   string s[3];   int N, M, p[3][1000005], a[3][1000005], b[1000005];   void genPrefix(int pat) {     int i, k;     p[pat][0] = 0;     k = 0;     i = 1;     while (i < M) {       if (s[pat][i] == s[pat][k]) {         k++;         p[pat][i] = k;         i++;       } else {         if (k != 0)           k = p[pat][k - 1];         else {           p[pat][i] = 0;           i++;         }       }     }   }   void KMPSearch(int txt, int pat) {     int i, k;     genPrefix(pat);     i = k = 0;     while (i < N) {       if (s[txt][i] == s[pat][k]) {         i++;         k++;         a[txt][i - k] = i - 1;       }       if (k == M) {         k = p[pat][k - 1];       } else if (i < N && s[txt][i] != s[pat][k]) {         if (k != 0) {           if (s[txt][i - 1] == s[pat][k])             a[txt][i - k] = max(i - 1, a[txt][k - 1]);           k = p[pat][k - 1];           if (k > 0 && s[txt][i - 1] == s[pat][k])             a[txt][i - k] = max(i - 1, a[txt][k - 1]);         } else           i++;       }     }   }   int bs(int low, int high, int v) {     int mid, x = -1;     while (low <= high) {       mid = (low + high) >> 1;       if (b[mid] >= v) {         x = mid;         high = mid - 1;       } else         low = mid + 1;     }     return x;   }   pair<int, int> solve() {     s[2] = s[0];     reverse(s[2].begin(), s[2].end());     memset(a, -1, sizeof(a));     KMPSearch(1, 2);     KMPSearch(0, 1);     b[0] = a[1][0];     int i, j = N, len, k, x;     int ansx = -1, ansy = -1;     for (i = 1; i <= N - 1; i++) b[i] = max(b[i - 1], a[1][i]);     for (i = 0; i <= N - 2; i++) {       j--;       if (s[0][i] != s[1][j]) break;       if (b[0] >= j - 1) {         ansx = i;         ansy = i + 1;       }       if (a[0][i + 1] <= 0 || i + 1 == N - 1) continue;       len = min(N - 2, a[0][i + 1]) - i;       k = bs(0, len, j - 1);       if (k >= 0 && ansx < i) {         ansx = i;         ansy = i + 1 + k;       }     }     return make_pair(ansx, ansy);   }   int main() {     std::ios_base::sync_with_stdio(0);     int cases, caseno = 0, n, i, j, k, cnt, m;     getline(cin, s[0]);     getline(cin, s[1]);     N = s[0].size();     M = s[1].size();     if (N != M) {       cout <<  -1 -1  <<   n ;       return 0;     }     pair<int, int> ans = solve();     cout << ans.first <<     << ans.second <<   n ;     return 0;   }   