#include <bits/stdc++.h>
using namespace std;
long long pw[1 << 21];
string st1, st2;
long long s1[1 << 20], s2[1 << 20], rs1[1 << 20], rs2[1 << 20];
int n;
int lcp[1 << 20];
int pref[1 << 20];
int lcp2[1 << 20];
int main() {
  ios_base::sync_with_stdio(0);
  pw[0] = 1;
  for (int i = 1; i <= (1 << 20); i++) pw[i] = pw[i - 1] * 173;
  getline(cin, st1);
  getline(cin, st2);
  if (st1.size() != st2.size()) {
    cout << -1 << " " << -1 << endl;
    return 0;
  }
  for (int i = 0; i < st1.size(); i++) s1[i + 1] = s1[i] + st1[i] * pw[i];
  for (int i = 0; i < st2.size(); i++) s2[i + 1] = s2[i] + st2[i] * pw[i];
  reverse(st1.begin(), st1.end());
  reverse(st2.begin(), st2.end());
  for (int i = 0; i < st1.size(); i++) rs1[i + 1] = rs1[i] + st1[i] * pw[i];
  for (int i = 0; i < st2.size(); i++) rs2[i + 1] = rs2[i] + st2[i] * pw[i];
  reverse(st1.begin(), st1.end());
  reverse(st2.begin(), st2.end());
  n = st1.size();
  for (int i = 1; i <= n; i++) {
    int l, r;
    l = 0;
    r = n - i + 1;
    while (l < r) {
      int mid = l + r + 1;
      mid /= 2;
      long long val1 = rs1[mid] * pw[1 << 20];
      long long val2 = (s2[i + mid - 1] - s2[i - 1]) * pw[(1 << 20) - i + 1];
      if (val1 == val2)
        l = mid;
      else
        r = mid - 1;
    }
    lcp[i] = l;
  }
  for (int i = 1; i <= n; i++) {
    int l, r;
    l = 0;
    r = n - i + 1;
    while (l < r) {
      int mid = l + r + 1;
      mid /= 2;
      long long val1 = s1[i + mid - 1] - s1[i - 1];
      val1 *= pw[(1 << 20) - i + 1];
      long long val2 = s2[mid] * pw[1 << 20];
      if (val1 == val2)
        l = mid;
      else
        r = mid - 1;
    }
    lcp2[i] = l;
  }
  for (int i = 1; i <= n + 1; i++) pref[i] = max(pref[i - 1], i + lcp[i]);
  for (int i = n - 1; i; i--) {
    long long val1 = s1[i] * pw[1 << 20];
    long long val2 = rs2[i] * pw[1 << 20];
    if (val1 != val2) continue;
    if (pref[lcp2[i + 1] + 1] <= n - i) continue;
    cout << i - 1 << " ";
    for (int j = 1; j <= st1.size(); j++) {
      if (lcp[j] + j > n - i) {
        cout << i + j - 1 << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << endl;
  return 0;
}
