#include <bits/stdc++.h>
using namespace std;
const int N = 1000005 * 2;
int n;
char a[N], b[N];
int Next[N], len[N];
unsigned long long Ha[2][N], Hb[2][N], Fac[2][N], T[2] = {233, 65537};
unsigned long long Get_Hash(unsigned long long *Ha, unsigned long long *Fac,
                            int L, int R) {
  if (L > R) L = n * 2 - L + 1, R = n * 2 - R + 1;
  return Ha[R] - Ha[L - 1] * Fac[R - L + 1];
}
void KMP(char *a, char *b, int n) {
  Next[1] = 0;
  for (int i = 2; i <= n; i++) {
    int k = Next[i - 1];
    while (k > 0 && a[k + 1] != a[i]) k = Next[k];
    if (a[k + 1] == a[i]) k++;
    Next[i] = k;
  }
  int k = 0;
  for (int i = 1; i <= n; i++) {
    while (k > 0 && a[k + 1] != b[i]) k = Next[k];
    if (a[k + 1] == b[i]) k++;
    len[i] = k;
  }
}
int Get(int j) {
  int L = 1, R = j - 1, mid, k1 = 0;
  while (L <= R) {
    mid = (L + R) >> 1;
    if (Get_Hash(Hb[0], Fac[0], 1, mid) ==
        Get_Hash(Ha[0], Fac[0], j - 1, j - mid))
      L = mid + 1, k1 = mid;
    else
      R = mid - 1;
  }
  if (k1 + len[j - 1] < j - 1) return -1;
  return len[j - 1];
}
int main() {
  gets(a + 1);
  gets(b + 1);
  n = strlen(a + 1);
  if (strlen(b + 1) != n) return puts("-1 -1"), 0;
  reverse(a + 1, a + n + 1);
  for (int i = n + 1; i <= n * 2; i++) {
    a[i] = a[n * 2 - i + 1];
    b[i] = b[n * 2 - i + 1];
  }
  KMP(a, b, n);
  for (int t = 0; t < 1; t++) {
    for (int i = Fac[t][0] = 1; i <= n * 2; i++)
      Fac[t][i] = Fac[t][i - 1] * T[t];
    for (int i = 1; i <= n * 2; i++) {
      Ha[t][i] = Ha[t][i - 1] * T[t] + a[i];
      Hb[t][i] = Hb[t][i - 1] * T[t] + b[i];
    }
  }
  int ansi = 10000000, ansj = 10000000;
  for (int j = n; j > 1; j--) {
    if (a[j] != b[j]) break;
    int i = Get(j);
    if (~i)
      if (j < ansj || (j == ansj && i > ansi)) ansi = i, ansj = j;
  }
  if (ansj == 10000000)
    ansi = ansj = -1;
  else
    ansi = n - ansi + 1 - 1, ansj = n - ansj + 1 - 1;
  printf("%d %d\n", ansj, ansi);
  return 0;
}
