#include <bits/stdc++.h>
using namespace std;
namespace IO {
const int __buffsize = 1000000;
char __buff[__buffsize];
char *__buffS, *__buffT;
char getch() {
  if (__buffS == __buffT) {
    __buffT = (__buffS = __buff) + fread(__buff, 1, __buffsize, stdin);
    if (__buffS == __buffT) return EOF;
  }
  return *__buffS++;
}
int read() {
  int T = 0, f = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (c >= '0' && c <= '9') {
    T = ((T << 1) + (T << 3)) + c - 48;
    c = getchar();
  }
  return T * f;
}
void write(int x) {
  if (x < 0) putchar('0'), x = -x;
  if (x >= 10) write(x / 10);
  putchar((x % 10) + '0');
}
void writeln(int x) {
  write(x);
  puts("");
}
};  // namespace IO
using namespace IO;
string s, t, a, b, ra;
int nxt[2000099], z[2000099], len, n;
void getnxt(string &s) {
  int len = s.length();
  nxt[0] = 0;
  for (int i = 1, k = 0; i < len; i++) {
    while (k && s[i] != s[k]) k = nxt[k - 1];
    if (s[i] == s[k]) k++;
    nxt[i] = k;
  }
}
void Z(string &s) {
  int l = 0, r = 0;
  int len = s.length();
  z[0] = len;
  for (int i = 1; i < len; i++) {
    int _i = i - l;
    int p = r - i + 1;
    if (i > r) {
      int x = i;
      while (x < len && s[x] == s[x - i]) x++;
      z[i] = x - i;
      if (x > i) {
        l = i;
        r = x - 1;
      }
    } else if (z[_i] >= p) {
      int x = r + 1;
      while (x < len && s[x] == s[x - i]) x++;
      z[i] = x - i;
      l = i;
      r = x - 1;
    } else
      z[i] = z[_i];
  }
}
int main() {
  ios::sync_with_stdio(false);
  getline(cin, a);
  getline(cin, b);
  n = a.length();
  if (n != b.length()) {
    puts("-1 -1");
    return 0;
  }
  ra = a;
  reverse(ra.begin(), ra.end());
  s = ra + (char)0 + b;
  t = b + (char)0 + a;
  getnxt(s);
  Z(t);
  int l = -1, r = -1;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] != b[n - i - 1]) break;
    if (z[n + i + 2] >= n - i - nxt[2 * n - i - 1] - 1) {
      l = i;
      r = n - nxt[2 * n - i - 1];
    }
  }
  printf("%d %d\n", l, r);
  return 0;
}
