#include <bits/stdc++.h>
using namespace std;
string a, b, ra;
string s, t;
int z[2001000], p[2001000];
int n;
void Z(string &s) {
  int l = 0, r = 0;
  int len = s.length();
  z[0] = len;
  for (int i = 1; i < len; i++) {
    int ii = i - l;
    int p = r + 1 - i;
    if (i > r) {
      int x = i;
      while (x < len && s[x] == s[x - i]) x++;
      z[i] = x - i;
      if (x > i) {
        l = i;
        r = x - 1;
      }
    } else if (z[ii] >= p) {
      int x = r + 1;
      while (x < len && s[x] == s[x - i]) x++;
      z[i] = x - i;
      l = i;
      r = x - 1;
    } else
      z[i] = z[ii];
  }
}
void kmp(string &s) {
  int len = s.length();
  for (int i = 1; i < len; i++) {
    p[i] = p[i - 1];
    while (p[i] > 0 && s[p[i]] != s[i]) p[i] = p[p[i] - 1];
    if (s[p[i]] == s[i]) p[i]++;
  }
}
int main() {
  ios::sync_with_stdio(false);
  getline(cin, a);
  getline(cin, b);
  n = a.length();
  if (n != b.length()) {
    cout << "-1 -1" << endl;
    return 0;
  }
  ra = a;
  reverse(ra.begin(), ra.end());
  s = ra + (char)0 + b;
  t = b + (char)0 + a;
  kmp(s);
  Z(t);
  int l, r;
  l = r = -1;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] != b[n - i - 1]) break;
    if (z[n + i + 2] >= n - i - p[2 * n - i - 1] - 1) {
      l = i;
      r = n - p[2 * n - i - 1];
    }
  }
  cout << l << ' ' << r << endl;
  return 0;
}
