#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T pow2(T a) {
  return a * a;
}
template <class T>
inline bool mineq(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
void calcZ(string str, int* Z) {
  int n = str.size(), l = 0, r = 0;
  Z[0] = 0;
  for (int i = 1; i < n; i++) {
    if (i > r) {
      l = r = i;
      while (r < n && str[r - l] == str[r]) r++;
      Z[i] = r - l;
      r--;
    } else {
      if (Z[i - l] < r - i + 1) {
        Z[i] = Z[i - l];
      } else {
        l = i;
        while (r < n && str[r - l] == str[r]) r++;
        Z[i] = r - l;
        r--;
      }
    }
  }
}
void calcP(string str, int* P) {
  int n = str.size(), j = 0;
  P[0] = 0;
  for (int i = 1; i < n; i++) {
    while (j > 0 && str[i] != str[j]) j = P[j - 1];
    if (str[i] == str[j]) P[i] = ++j;
  }
}
const int maxn = (int)3e6 + 10;
;
int p[maxn], z[maxn];
char s[maxn];
string t, t1, s1, s2;
inline string r(string k) {
  reverse(k.begin(), k.end());
  return k;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  srand(time(0));
  cin.getline(s, maxn);
  t = s;
  cin.getline(s, maxn);
  t1 = s;
  int n = t.size();
  if (t1.size() != n) {
    cout << "-1 -1";
    return 0;
  }
  char c = 0;
  string g;
  g.push_back(c);
  s1 = r(t) + g + t1;
  s2 = t1 + g + t;
  calcZ(s2, z);
  calcP(s1, p);
  int pa = -1, q = -1;
  for (int i = 0; i < n - 1; i++) {
    if (t[i] != t1[n - i - 1]) break;
    int j = p[2 * n - i - 1];
    if (z[n + 1 + i + 1] >= n - j - 1 - i) {
      pa = i;
      q = n - j;
    }
  }
  cout << pa << " " << q;
  return 0;
}
