#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:65777216")
using namespace std;
string t;
int p[2222222];
string t2;
int z[2222222];
string a, b;
int n;
bool good(int i, int j) { return z[n + i + 2] >= j - i - 1; }
int getJ(int i) {
  int best = n - p[2 * n - i - 1] - 1;
  if (good(i, best)) return best;
  return -1;
}
int main() {
  getline(cin, a);
  getline(cin, b);
  if (a.size() != b.size()) {
    puts("-1 -1");
    return 0;
  }
  n = a.size();
  t = a;
  reverse(t.begin(), t.end());
  t.push_back(0);
  t += b;
  int curr = -1;
  p[0] = -1;
  for (int i = 1; i <= 2 * n; i++) {
    while (curr >= 0 && t[i] != t[curr + 1]) curr = p[curr];
    if (t[i] == t[curr + 1]) curr++;
    p[i] = curr;
  }
  t2 = b;
  t2.push_back(0);
  t2 += a;
  int l = 0, r = 0;
  for (int i = 1; i < t2.size(); i++) {
    if (i < r) z[i] = min(r - i, z[i - l]);
    while (i + z[i] < t2.size() && t2[i + z[i]] == t2[z[i]]) z[i]++;
    if (i + z[i] > r) l = i, r = i + z[i];
  }
  int r1 = -1, r2 = -1;
  for (int i(0); i < (n - 1); i++) {
    if (a[i] != b[n - 1 - i]) break;
    int j = getJ(i);
    if (j == -1) continue;
    r1 = i, r2 = j;
  }
  cout << r1 << ' ' << r2 << endl;
  return 0;
}
