#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010000;
char a[maxn], b[maxn], Ra[maxn];
int n, p[2] = {1000000007, 5492}, mo[2] = {100000007, 799999997};
long long power[2][maxn], ha[2][maxn], hb[2][maxn];
int minj[maxn], f[maxn];
bool equal(int i, int j) {
  if (i > j) return true;
  int len = j - i;
  for (int o = 0; o <= 0; o++)
    if (ha[o][j + 1] - ha[o][i] != hb[o][len + 1] * power[o][i]) return false;
  return true;
}
int main() {
  gets(a);
  n = strlen(a);
  gets(b);
  if (strlen(b) != n || n == 1) {
    cout << "-1 -1\n";
    return 0;
  }
  int Maxi = -1;
  for (int i = 0; i <= n - 1; i++)
    if (a[i] == b[n - i - 1])
      Maxi = i;
    else
      break;
  if (Maxi == -1) {
    cout << "-1 -1\n";
    return 0;
  }
  if (Maxi > n - 2) Maxi = n - 2;
  for (int o = 0; o <= 0; o++) power[o][0] = 1, ha[o][0] = hb[o][0] = 0;
  for (int o = 0; o <= 0; o++)
    for (int i = 0; i <= n - 1; i++)
      power[o][i + 1] = power[o][i] * p[o],
                   ha[o][i + 1] = (ha[o][i] + power[o][i] * a[i]),
                   hb[o][i + 1] = (hb[o][i] + power[o][i] * b[i]);
  for (int i = 0; i <= n - 1; i++) Ra[i] = a[n - 1 - i];
  f[0] = -1;
  int k = -1;
  for (int i = 1; i <= n - 1; i++) {
    while (k != -1 && Ra[k + 1] != Ra[i]) k = f[k];
    if (Ra[k + 1] == Ra[i]) ++k;
    f[i] = k;
  }
  k = -1;
  for (int ii = n - 2; ii > -1; ii--) {
    int i = n - ii - 2;
    while (k != -1 && Ra[k + 1] != b[i]) k = f[k];
    if (Ra[k + 1] == b[i]) ++k;
    if (k != -1)
      minj[ii] = n - (k + 1);
    else
      minj[ii] = -1;
  }
  int ansi = -1, ansj = -1;
  for (int i = 0; i <= Maxi; i++)
    if (minj[i] != -1) {
      if (equal(i + 1, minj[i] - 1)) {
        ansi = i;
        ansj = minj[i];
      }
    }
  cout << ansi << " " << ansj << endl;
  return 0;
}
