#include <bits/stdc++.h>
using namespace std;
string a, b;
int nex[1000006], f1[1000006], f2[1000006];
long long xa[1000006], xb[1000006], mu[1000006];
const long long base = 1000000007;
int main() {
  getline(cin, a);
  getline(cin, b);
  if (a.length() != b.length()) {
    cout << "-1 -1";
    return 0;
  }
  int n = a.length();
  nex[n - 1] = n;
  for (int i = n - 2; i >= 0; i--) {
    int j = nex[i + 1];
    while (j < n && a[j - 1] != a[i]) j = nex[j];
    if (j - 1 >= 0 && a[i] == a[j - 1])
      nex[i] = j - 1;
    else
      nex[i] = j;
  }
  int j = n;
  for (int i = 0; i <= n - 1; i++) {
    while (j < n && b[i] != a[j - 1]) j = nex[j];
    if (j - 1 >= 0 && b[i] == a[j - 1]) j--;
    f1[i] = j;
  }
  mu[0] = 1;
  for (int i = 1; i <= n; i++) mu[i] = (mu[i - 1] * 95) % base;
  xa[0] = a[0] - 32;
  for (int i = 1; i <= n - 1; i++)
    xa[i] = (xa[i - 1] + mu[i] * (a[i] - 32)) % base;
  xb[0] = b[0] - 32;
  for (int i = 1; i <= n - 1; i++)
    xb[i] = (xb[i - 1] + mu[i] * (b[i] - 32)) % base;
  int res1 = -1, res2 = -1;
  for (int i = 0; i <= n - 2 && a[i] == b[n - i - 1]; i++) {
    if (a[i] != b[n - i - 1]) break;
    int j = f1[n - i - 2];
    if (j < n && (j == i + 1 || (xa[j - 1] - xa[i] + base) % base ==
                                    (xb[j - i - 2] * mu[i + 1]) % base)) {
      res1 = i;
      res2 = j;
    }
  }
  cout << res1 << " " << res2;
  return 0;
}
