#include <bits/stdc++.h>
using namespace std;
void Z(vector<int> x, vector<int>& z) {
  int n = x.size() - 1;
  z[1] = 0;
  int l = 0, p = 0;
  for (int i = 2; i <= n; ++i) {
    if (i > p) {
      l = p = i;
      while (p <= n && x[p] == x[p - l + 1]) ++p;
      --p;
      z[i] = p - l + 1;
    } else {
      if (z[i - l + 1] < p - i + 1)
        z[i] = z[i - l + 1];
      else {
        l = i;
        while (p <= n && x[p] == x[p - l + 1]) ++p;
        --p;
        z[i] = p - l + 1;
      }
    }
  }
}
void Pref(vector<int> y, vector<int>& pref) {
  int n = y.size() - 1;
  pref[1] = 0;
  for (int i = 2; i <= n; ++i) {
    int k = pref[i - 1];
    while (k > 0 && y[k + 1] != y[i]) k = pref[k];
    if (k == 0) {
      if (y[1] == y[i])
        pref[i] = 1;
      else
        pref[i] = 0;
    } else
      pref[i] = k + 1;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  string t1, t2;
  getline(cin, t1);
  getline(cin, t2);
  if (t1.size() != t2.size() || t1.size() == 1) {
    cout << "-1 -1";
    return 0;
  }
  int n = t1.size();
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) {
    a[i] = t1[i];
    b[i] = t2[i];
  }
  vector<int> x;
  x.push_back(0);
  for (int i = n - 1; i >= 0; --i) x.push_back(a[i]);
  x.push_back(0);
  for (int i = 0; i < n; ++i) x.push_back(b[i]);
  vector<int> pref(x.size());
  Pref(x, pref);
  vector<int> y;
  y.push_back(0);
  for (int i = 0; i < n; ++i) y.push_back(b[i]);
  y.push_back(0);
  for (int i = 0; i < n; ++i) y.push_back(a[i]);
  vector<int> z(y.size());
  Z(y, z);
  int odpI = -1, odpJ = -1;
  for (int p = 1; p + 1 <= n; ++p) {
    if (a[p - 1] != b[n - p]) break;
    int s = pref[2 * n + 1 - p];
    if (s == 0) continue;
    if (s + p == n) {
      odpI = p - 1;
      odpJ = p;
    } else {
      int m = n - p - s;
      if (z[n + 1 + p + 1] >= m) {
        odpI = p - 1;
        odpJ = p + m;
      }
    }
  }
  cout << odpI << " " << odpJ;
  return 0;
}
