#include <bits/stdc++.h>
using namespace std;
char s[1000010], t[1000010], temp[1000010];
int p[2000010], f[2000010];
string s1, s2;
int main() {
  s1 = "";
  s2 = "";
  gets(s);
  gets(t);
  if (strlen(s) != strlen(t)) {
    printf("-1 -1\n");
    return 0;
  }
  int n = strlen(s);
  for (int i = 0; i < n; i++) temp[i] = s[n - 1 - i];
  s1 += temp;
  s1 += '\0';
  s1 += t;
  s2 += t;
  s2 += '\0';
  s2 += s;
  p[0] = -1;
  int j = -1;
  for (int i = 1; i < 2 * n + 1; i++) {
    while (j >= 0 && s1[j + 1] != s1[i]) j = p[j];
    if (s1[j + 1] == s1[i]) j++;
    p[i] = j;
  }
  j = 0;
  int maxx = -1;
  memset(f, -1, sizeof(f));
  for (int i = 1; i < 2 * n + 1; i++) {
    if (maxx >= i) f[i] = min(f[i - j], maxx - i);
    while ((i + f[i] + 1 < 2 * n + 1) && (s2[f[i] + 1] == s2[i + f[i] + 1]))
      f[i]++;
    if (i + f[i] > maxx) {
      maxx = i + f[i];
      j = i;
    }
  }
  int ans1 = -1, ans2 = -1;
  for (int i = 0; i < n - 1; i++) {
    if (s[i] != t[n - 1 - i]) break;
    int x = p[2 * n - i - 1];
    int y = f[n + i + 2];
    if (x + 1 + y + 1 + i + 1 >= n) {
      ans1 = i;
      ans2 = ans1 + (n - i - 1 - x);
    }
  }
  printf("%d %d\n", ans1, ans2);
  return 0;
}
