#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
const int MX = 2000006;
char a[MX], b[MX];
char arb[MX], abr[MX], ba[MX];
int parb[MX], zabr[MX], zba[MX], pos[MX];
void compute_pi(int n, char s[], int pi[]) {
  pi[0] = 0;
  for (int i = 1; i < n; i++) {
    int j = pi[i - 1];
    while (j) {
      if (s[j] == s[i]) {
        pi[i] = j + 1;
        break;
      }
      j = pi[j - 1];
    }
    if (j == 0) pi[i] = (s[i] == s[0]) ? 1 : 0;
  }
}
void compute_z(int n, char s[], int z[]) {
  int l = 0, r = 0;
  for (int i = 1; i < n; i++) {
    if (i <= r) z[i] = min(z[i - l], r - i + 1);
    for (int j = i + z[i], p = z[i]; j < n; j++, p++) {
      if (s[p] == s[j])
        z[i]++;
      else
        break;
    }
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
  }
}
void calc(int n, int m) {
  compute_pi(n + m + 1, arb, parb);
  compute_z(n + m + 1, abr, zabr);
  compute_z(n + m + 1, ba, zba);
  memset(pos, -1, sizeof(pos));
  for (int i = n + 1, p = 0; i <= n + m; i++, p++) {
    if (parb[i] < 1) continue;
    int j = p - parb[i] + 1;
    if (pos[p] == -1) pos[p] = j;
  }
}
void make(int n, int m) {
  char sep[] = " ";
  sep[0] = 31;
  strcpy(ba, b);
  strcat(ba, sep);
  strcat(ba, a);
  strcpy(arb, a);
  reverse(arb, arb + n);
  strcat(arb, sep);
  strcat(arb, b);
  strcpy(abr, a);
  reverse(b, b + m);
  strcat(abr, sep);
  strcat(abr, b);
}
int main() {
  gets(a), gets(b);
  int n = strlen(a), m = strlen(b);
  make(n, m);
  calc(n, m);
  int x = -1, y = -1;
  for (int i = m + 2; (i <= n + m && n == m); i++) {
    int p = pos[n + m - i];
    if (p < 0 || p > zba[i]) continue;
    if (zabr[n + 1] >= i - m - 1) x = i - m - 2, y = i - m - 1 + p;
  }
  printf("%d %d\n", x, y);
  return 0;
}
