#include <bits/stdc++.h>
using namespace std;
template <typename T, typename TT>
ostream &operator<<(ostream &s, pair<T, TT> t) {
  return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream &operator<<(ostream &s, vector<T> t) {
  s << "{";
  for (int i = 0; i < t.size(); i++)
    s << t[i] << (i == t.size() - 1 ? "" : ",");
  return s << "}" << endl;
}
char s[1000003];
char t[1000003];
int n;
unsigned long long hasze[1000003];
unsigned long long haszet[1000003];
unsigned long long haszer[1000003];
unsigned long long pX[1000003];
inline unsigned long long h(int a, int b) {
  return hasze[a] - pX[b - a] * hasze[b];
}
inline unsigned long long hr(int a, int b) {
  return haszer[a] - pX[b - a] * haszer[b];
}
inline unsigned long long ht(int a, int b) {
  return haszet[a] - pX[b - a] * haszet[b];
}
int mxtyl[1000003];
int prefmx[1000003];
int main() {
  pX[0] = 1;
  for (int i = 1; i <= 1000003 - 1; i++) pX[i] = 29 * pX[i - 1];
  gets(s);
  n = strlen(s);
  hasze[n] = 0;
  for (int i = n - 1; i >= 0; i--) hasze[i] = hasze[i + 1] * 29 + s[i];
  haszer[n] = 0;
  for (int i = n - 1; i >= 0; i--)
    haszer[i] = haszer[i + 1] + s[i] * pX[n - 1 - i];
  gets(t);
  int m = strlen(t);
  if (m != n) {
    cout << "-1 -1\n";
    return 0;
  }
  haszet[n] = 0;
  for (int i = n - 1; i >= 0; i--) haszet[i] = haszet[i + 1] * 29 + t[i];
  ;
  for (int i = 0; i < n; i++) {
    int lo = 0, hi = n, mid;
    while (hi - lo > 1) {
      mid = (lo + hi) / 2;
      if (haszer[n - mid] == ht(i, i + mid))
        lo = mid;
      else
        hi = mid;
    }
    mxtyl[i] = lo + i;
    ;
    ;
  }
  prefmx[0] = -1;
  for (int i = 1; i <= n; i++) prefmx[i] = max(prefmx[i - 1], mxtyl[i - 1]);
  int i0 = 0;
  while (i0 < n - 1 && t[n - 1 - i0] == s[i0]) i0++;
  i0--;
  for (int i = i0; i >= 0; i--) {
    int lo = i + 1, hi = n, mid;
    while (hi - lo > 1) {
      mid = (lo + hi) / 2;
      if (h(i + 1, mid) == ht(0, mid - i - 1))
        lo = mid;
      else
        hi = mid;
    }
    int dl = lo - i - 1;
    ;
    int mx = 0;
    mx = prefmx[dl + 1];
    ;
    if (mx + i + 1 >= n) {
      for (int j = i + 1; j <= n; j++) {
        ;
        ;
        ;
        if (haszer[j] == ht(j - 1 - i, n - i - 1)) {
          cout << i << " " << j;
          return 0;
        }
      }
    };
  }
  cout << "-1 -1\n";
  return 0;
}
