#include <bits/stdc++.h>
using namespace std;
const int MaxN = (int)1e6 + 10;
const int inf = (int)0x7f7f7f7f;
int f[MaxN];
vector<int> ZFunction(string st) {
  int n = st.size();
  vector<int> z(n, 0);
  for (int i = 1, l = 0, r = 0; i < n; ++i) {
    if (i <= r) z[i] = min(z[i - l], r - i + 1);
    while (i + z[i] < n && st[i + z[i]] == st[z[i]]) z[i]++;
    if (r < i + z[i] - 1) {
      l = i;
      r = i + z[i] - 1;
    }
  }
  return z;
}
int main() {
  string a, b;
  int n, m;
  getline(cin, a);
  n = a.size();
  getline(cin, b);
  m = b.size();
  if (n != m) {
    cout << "-1 -1";
    return 0;
  }
  string ra = a;
  reverse(ra.begin(), ra.end());
  vector<int> z0 = ZFunction(b + char(0) + a);
  vector<int> z1 = ZFunction(ra + char(0) + b);
  memset(f, inf, sizeof f);
  for (int i = 0; i < n; ++i) {
    int &x = f[min(n - 1, i + z1[i + n + 1] - 1)];
    x = min(x, i);
  }
  for (int i = n - 1; i >= 0; --i) f[i] = min(f[i], f[i + 1]);
  pair<int, int> ans(-1, -1);
  for (int i = 0; i < n - 1; ++i) {
    if (a[i] != b[n - i - 1]) break;
    int p = f[n - i - 2];
    if (z0[i + 1 + n + 1] >= p) ans = make_pair(i, i + p + 1);
  }
  printf("%d %d", ans.first, ans.second);
  return 0;
}
