#include <bits/stdc++.h>
using namespace std;
int n;
inline bool is_p(int x) {
  for (int i = 2; i * i <= x; ++i)
    if (x % i == 0) return false;
  return true;
}
char a[1111111], b[1111111];
int f[1111111], g[1111111];
int r[1111111];
void exkmp(char* a, char* b, int* sek, int* ex) {
  int qwq = -1, p = 0;
  memset(ex, 0, sizeof(int) * (n + 10));
  for (int i = (sek == ex); i < n; ++i) {
    if (p < i) p = i;
    for (ex[i] = ((p - i) < (sek[i - qwq]) ? (p - i) : (sek[i - qwq]));
         i + ex[i] < n; ++ex[i])
      if (a[i + ex[i]] != b[ex[i]]) break;
    if (i + ex[i] > p) {
      p = i + ex[i];
      qwq = i;
    }
  }
}
void match(char* a, char* b, int* f) {
  static int sek[1111111];
  exkmp(b, b, sek, sek);
  exkmp(a, b, sek, f);
}
int main() {
  cin.getline(a, 1048576);
  cin.getline(b, 1048576);
  n = strlen(a);
  if (strlen(a) != strlen(b)) return puts("-1 -1"), 0;
  match(a, b, g);
  reverse(a, a + n);
  match(b, a, f);
  int lim = n - 1;
  for (; lim && a[lim] == b[lim]; --lim)
    ;
  lim = n - 1 - lim;
  memset(r, 0x3f, sizeof(r));
  for (int i = n; i-- > 0; r[i] = i) r[f[i] + i] = i;
  for (int i = n; i-- > 0;)
    if (r[i + 1] < r[i]) r[i] = r[i + 1];
  for (int i = lim; i-- > 0;)
    if (r[n - i - 1] <= g[i + 1])
      return printf("%d %d\n", i, i + r[n - i - 1] + 1), 0;
  puts("-1 -1");
  return 0;
}
