#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
const int NN = 2 * N + 10;
const long long MOD = 1000000007;
char x[NN], y[NN], s[NN];
long long P[NN], H1[NN], H2[NN];
void solve() {
  int n, i, j, k, ai, aj;
  gets(x);
  gets(y);
  n = strlen(x);
  if (strlen(y) != n) {
    printf("-1 -1");
    return;
  }
  for (i = 0; i < n; i++) {
    s[i] = x[n - 1 - i];
    s[n + 1 + i] = y[i];
  }
  k = P[0] = -1;
  for (i = 1; i < 2 * n + 1; i++) {
    while (k >= 0 && s[k + 1] != s[i]) k = P[k];
    if (s[k + 1] == s[i]) k++;
    P[i] = k;
  }
  ai = aj = -1;
  for (i = 0, P[0] = 1; i < n; i++) {
    H1[i] = (H1[i - 1] + P[i] * (x[i] - 31)) % MOD;
    H2[i] = (H2[i - 1] + P[i] * (y[i] - 31)) % MOD;
    P[i + 1] = P[i] * (128 - 32) % MOD;
  }
  for (i = 0; i + 1 < n && x[i] == y[n - 1 - i]; i++) {
    j = n - (P[2 * n - 1 - i] + 1);
    if (j == n) continue;
    if (H2[j - i - 2] * P[i + 1] % MOD == (H1[j - 1] - H1[i] + MOD) % MOD) {
      ai = i;
      aj = j;
    }
  }
  printf("%d %d", ai, aj);
}
int main() {
  solve();
  return 0;
}
