#include <bits/stdc++.h>
using namespace std;
char a[1000050], b[1000050], s[1000050 << 1];
int nex[2000010], n, pre[2000010], pw[1000050], ans1, ans2;
int main() {
  cin.getline(a + 1, 1000050);
  cin.getline(b + 1, 1000050);
  if (strlen(a + 1) != strlen(b + 1)) {
    puts("-1 -1");
    return 0;
  }
  n = strlen(a + 1);
  for (int i = 1; i <= n; ++i) s[i] = a[n - i + 1];
  s[n + 1] = 0;
  for (int i = 1; i <= n; ++i) s[i + n + 1] = b[i];
  nex[0] = -1;
  for (int i = 1, j = -1; i <= (n << 1) + 1; nex[i++] = ++j)
    while (j >= 0 && s[i] != s[j + 1]) j = nex[j];
  for (int i = 1; i <= n; ++i) s[i] = b[i];
  s[n + 1] = 0;
  for (int i = 1; i <= n; ++i) s[i + n + 1] = a[i];
  pre[1] = 2 * n + 1;
  while (s[2 + pre[2]] == s[1 + pre[2]] && 2 + pre[2] <= 2 * n + 1) ++pre[2];
  int p = 2;
  for (int i = 3; i <= 2 * n + 1; ++i) {
    if (pre[i - p + 1] < pre[p] + p - i)
      pre[i] = pre[i - p + 1];
    else {
      int j = max(0, p + pre[p] - i);
      while (s[i + j] == s[1 + j] && i + j <= 2 * n + 1) ++j;
      pre[i] = j;
      p = i;
    }
  }
  ans1 = ans2 = -1;
  for (int i = 1; i <= n; ++i) {
    int r = pre[i + n + 1] + i, l = nex[2 * n + 1 - (i - 1)];
    if (n - l + 1 <= r) ans1 = i - 2, ans2 = n - l;
    if (a[i] != b[n - i + 1]) break;
  }
  if (ans1 == -1) ans2 = -1;
  printf("%d %d\n", ans1, ans2);
  return 0;
}
