#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e6 + 5;
int p[MAXN], z[MAXN];
void get_zfun(string s) {
  int n = s.length();
  for (int i = 1, l = 0, r = 0; i < n; i++) {
    if (i <= r) {
      z[i] = min(r - i + 1, z[i - l]);
    }
    while (i + z[i] < n && s[i + z[i]] == s[z[i]]) {
      z[i]++;
    }
    if (i + z[i] - 1 > r) {
      l = i;
      r = i + z[i] - 1;
    }
  }
}
void get_pi(string s) {
  int n = s.length();
  for (int i = 1; i < n; i++) {
    int j = p[i - 1];
    while (j > 0 && s[j] != s[i]) {
      j = p[j - 1];
    }
    if (s[i] == s[j]) j++;
    p[i] = j;
  }
}
void solve() {
  string a, b;
  getline(cin, a);
  getline(cin, b);
  if ((int)a.length() != (int)b.length()) {
    cout << "-1 -1";
    return;
  }
  char c = 31;
  string fs = b + c + a;
  reverse(a.begin(), a.end());
  string sc = a + c + b;
  get_zfun(fs);
  get_pi(sc);
  int ansi = -1, ansj = -1;
  int n = a.length();
  reverse(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    if (a[i] != b[n - i - 1]) break;
    int j = n - p[2 * n - 1 - i];
    if (j < n && z[n + 2 + i] >= j - i - 1) {
      ansi = i;
      ansj = j;
    }
  }
  cout << ansi << " " << ansj;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
