#include <bits/stdc++.h>
using namespace std;
int z[2 * 1000100], x[1 << 21], p = 1 << 20;
char s[2 * 1000100];
int get(int j, int v) {
  for (j += p; j && x[j] < v; j = (j - 1) / 2)
    ;
  if (!j) return -1;
  for (; j < p; j *= 2, j += x[j + 1] >= v)
    ;
  return j - p;
}
void zf(const string &s) {
  int i, l, r, j, n;
  n = s.size();
  for (r = 0, i = 1; i < n; z[i] = j - i, i++) {
    if (i >= r)
      j = i;
    else if (i + z[i - l] >= r)
      j = r;
    else
      j = i + z[i - l];
    for (; s[j] == s[j - i]; j++)
      ;
    if (j > r) {
      l = i;
      r = j;
    }
  }
}
string rev(string s) {
  reverse(s.begin(), s.end());
  return s;
}
int main() {
  string a, b, d;
  d = " ";
  d[0] = 30;
  gets(s);
  a = s;
  gets(s);
  b = s;
  if (a.size() != b.size()) {
    printf("-1 -1\n");
    return 0;
  }
  int n = a.size();
  int f, l, h;
  for (f = 0; f < n && a[f] == b[n - 1 - f]; f++)
    ;
  string t = b + d + a;
  zf(t);
  for (int i = 0; i < n; x[i + p] = z[n + 1 + i], i++)
    ;
  for (int i = p - 1; i > 0; x[i] = max(x[2 * i], x[2 * i + 1]), i--)
    ;
  string c = rev(a) + d + b;
  zf(c);
  int bi, bj;
  bi = -1;
  bj = n;
  for (l = 0; l <= n; l++) {
    h = z[n + 1 + l];
    int i, j;
    i = max(n - h - l, 1);
    j = min(f, n - 1 - l);
    if (i <= j) {
      h = get(j, l);
      if (h >= i) {
        if (h - 1 > bi) {
          bi = h - 1;
          bj = h + l;
        } else if (h - 1 == bi && h + l < bj)
          bj = h + l;
      }
    }
  }
  if (bi == -1)
    printf("-1 -1\n");
  else
    printf("%d %d\n", bi, bj);
  return 0;
}
