#include <bits/stdc++.h>
using namespace std;
vector<int> calcP(const char* s, int n) {
  vector<int> P(n);
  for (int x = 0, y = 1; y < n; y++) {
    while (x && s[x] != s[y]) x = P[x - 1];
    if (s[x] == s[y]) P[y] = ++x;
  }
  return P;
}
vector<int> calcZ(const char* s, int n) {
  vector<int> Z(n, n);
  for (int i = 1, x = 0, y = 0; i < n; i++) {
    Z[i] = min(max(y - i, 0), Z[i - x]);
    while (i + Z[i] < n && s[i + Z[i]] == s[Z[i]]) Z[i]++;
    if (y <= i + Z[i]) x = i, y = i + Z[i];
  }
  return Z;
}
char s[1000005];
int main() {
  string x = gets(s);
  string y = gets(s);
  if (x.size() != y.size()) return puts("-1 -1") & 0;
  int n = x.size(), p = -1, q = -1;
  string u = x, v = y;
  reverse(u.begin(), u.end());
  u += '\t' + y + '\n';
  v += '\t' + x + '\n';
  auto P = calcP(u.c_str(), u.size());
  auto Z = calcZ(v.c_str(), v.size());
  for (int i = 0; i < n; i++) {
    if (x[i] != y[n - i - 1]) break;
    int j = n - P[2 * n - i - 1];
    if (j < n && Z[n + i + 2] >= j - i - 1) p = i, q = j;
  }
  printf("%d %d\n", p, q);
}
