#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 5;
string a, b, c = " ";
int n, z[N], ext[N], f[N], nxt[N], mxi;
int main() {
  getline(cin, a), getline(cin, b);
  if (a.size() != b.size()) {
    printf("-1 -1\n");
    return 0;
  }
  n = a.size(), a = ' ' + a, b = ' ' + b;
  for (int i = n; i; i--) c += a[i];
  z[1] = n;
  for (int i = 2, l = 0, r = 0; i <= n; i++) {
    if (i <= r) z[i] = min(r - i + 1, z[i - l + 1]);
    while (i + z[i] <= n && b[i + z[i]] == b[z[i] + 1]) z[i]++;
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
  }
  for (int i = 1, l = 0, r = 0; i <= n; i++) {
    if (i <= r) ext[i] = min(r - i + 1, z[i - l + 1]);
    while (i + ext[i] <= n && a[i + ext[i]] == b[ext[i] + 1]) ext[i]++;
    if (i + ext[i] - 1 > r) l = i, r = i + ext[i] - 1;
  }
  for (int i = 2, j = 0; i <= n; i++) {
    while (j && c[j + 1] != c[i]) j = nxt[j];
    if (c[j + 1] == c[i]) j++;
    nxt[i] = j;
  }
  for (int i = 1, j = 0; i <= n; i++) {
    while (j && c[j + 1] != b[i]) j = nxt[j];
    if (c[j + 1] == b[i]) j++;
    f[i] = j;
  }
  while (mxi < n - 1 && a[mxi + 1] == b[n - mxi]) mxi++;
  for (int i = mxi, j; i; i--)
    if ((j = n - f[n - i]) <= i + ext[i + 1]) {
      printf("%d %d\n", i - 1, j);
      return 0;
    }
  printf("-1 -1\n");
  return 0;
}
