#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int best[1000000 + 10];
string a, b;
string ra = "", rb = "";
string s;
int mosti;
int len1, len2;
int z[2000000 + 10];
int flag[1000000 + 10];
int finalz[1000000 + 10];
void calc() {
  memset(z, 0, sizeof(z));
  int n = s.length();
  s = ' ' + s;
  int l_bound, r_bound;
  for (int i = 2; i <= n; ++i) {
    if (s[i] != s[i - 1]) {
      break;
    }
    z[2]++;
  }
  l_bound = 2, r_bound = z[2] + 1;
  for (int i = 3; i <= n; ++i) {
    if (i <= r_bound) {
      z[i] = z[i - l_bound + 1];
      z[i] = min(z[i], r_bound - i + 1);
      if (z[i] + i - 1 == r_bound) {
        int ite = z[i] + 1;
        for (int j = r_bound + 1; j <= n; ++j) {
          if (s[j] != s[ite++]) break;
          z[i]++;
        }
        l_bound = i, r_bound = z[i] + i - 1;
      }
    } else {
      int ite = 1;
      for (int j = i; j <= n; ++j) {
        if (s[j] != s[ite++]) break;
        z[i]++;
      }
      l_bound = i;
      r_bound = i + z[i] - 1;
    }
  }
}
int main() {
  getline(cin, a);
  getline(cin, b);
  len1 = a.length(), len2 = b.length();
  if (len1 != len2) {
    puts("-1 -1");
    return 0;
  }
  for (int i = len1 - 1; i >= 0; --i) ra += a[i];
  for (int i = len1 - 1; i >= 0; --i) rb += b[i];
  s = rb + a;
  calc();
  mosti = z[len1 + 1];
  s = ra + b;
  calc();
  for (int i = 1; i <= len1; ++i) {
    int is = i + len1;
    flag[i] = z[is];
  }
  int go_to = 0;
  for (int i = 1; i <= len1; ++i) {
    if (flag[i]) {
      for (int j = max(go_to + 1, i); j <= i + flag[i] - 1; ++j) {
        go_to = j;
        best[j] = j - i + 1;
      }
    }
  }
  s = b + a;
  calc();
  for (int i = 1; i <= len1; ++i) {
    finalz[i] = z[i + len1];
  }
  pair<int, int> RES = {0, 0};
  for (int i = 1; i <= mosti; ++i) {
    if (i == len1) break;
    int tmpj = len1 - best[len1 - i] + 1;
    if (finalz[i + 1] + i >= tmpj - 1) RES = {i, tmpj};
  }
  cout << RES.first - 1 << " " << RES.second - 1 << endl;
  return 0;
}
