#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
const int M = 1e6 + 10;
const long long base = 311;
const int digit = 9;
const int mod = 1e9 + 7;
int z[2 * N], p[2 * N];
void prefunc(string s) {
  int n = s.size();
  p[0] = 0;
  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 zfunc(string s) {
  int n = s.size();
  z[0] = 0;
  int l = 0, r = 0;
  for (int i = 1; i < n; i++) {
    if (i <= r) z[i] = min(z[i - l], r - i + 1);
    while (z[i] + i < n && s[z[i]] == s[z[i] + i]) z[i]++;
    if (r < z[i] + i - 1) {
      r = z[i] + i - 1;
      l = i;
    }
  }
}
string a, b, s1, s2;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  getline(cin, a);
  getline(cin, b);
  int n = a.size();
  if (n != b.size()) {
    cout << -1 << " " << -1;
    return 0;
  }
  s1 = a;
  reverse(s1.begin(), s1.end());
  s1 += "0" + b;
  s2 = b + "0" + a;
  prefunc(s1);
  zfunc(s2);
  int resi, resj;
  resi = resj = -1;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] != b[n - 1 - i]) break;
    int d = p[2 * n - i - 1];
    if (z[n + i + 2] >= n - i - 1 - d) {
      resi = i;
      resj = n - d;
    }
  }
  cout << resi << " " << resj;
  return 0;
}
