#include <bits/stdc++.h>
using namespace std;
char a[1000010], b[1000010];
int p[2000010], z[2000010];
char str[2000010];
int n;
int main() {
  gets(a);
  gets(b);
  if ((n = strlen(a)) != strlen(b)) {
    printf("-1 -1\n");
    return 0;
  }
  for (int i = 0; i < n; i++) str[i] = a[n - i - 1];
  str[n] = '\0';
  for (int i = 0; i < n; i++) str[n + i + 1] = b[i];
  p[1] = 0;
  for (int i = 2, j = 0; i <= 2 * n + 1; i++) {
    while ((j > 0) && str[j] != str[i - 1]) j = p[j];
    p[i] = (j = (j + (str[i - 1] == str[j])));
  }
  for (int i = 0; i < n; i++) str[i] = b[i];
  str[n] = '\0';
  for (int i = 0; i < n; i++) str[n + i + 1] = a[i];
  z[1] = 0;
  for (int i = 2, l = 1, r = 1; i < 2 * n + 1; ++i) {
    z[i] = 0;
    if (i <= r) z[i] = min(z[i - l + 1], r - i + 1);
    while (i + z[i] <= 2 * n + 1 && str[z[i]] == str[i + z[i] - 1]) ++z[i];
    if (i + z[i] - 1 > r) {
      l = i;
      r = i + z[i] - 1;
    }
  }
  int ansi = 0, ansj = -1;
  for (int i = 1; i < n; i++) {
    if (a[i - 1] != b[n - i]) break;
    int j = n - p[2 * n + 1 - i];
    if (z[n + 2 + i] + i >= j) {
      ansi = i;
      ansj = j;
    }
  }
  printf("%d %d\n", ansi - 1, ansj);
  return 0;
}
