#include <bits/stdc++.h>
using namespace std;
char _a[2010000], _b[2010000];
int g1[2010000], g2[2010000];
void cal(string a, int f[]) {
  f[1] = 0;
  while (a[f[1]] == a[f[1] + 1]) f[1]++;
  int mx = 1, n = ((int)((a).size()));
  for (int i = (2); i <= (n - 1); i++) {
    if (f[mx] + mx > i)
      f[i] = min(f[i - mx], f[mx] + mx - i);
    else
      f[i] = 0;
    while (a[f[i]] == a[f[i] + i]) f[i]++;
    if (f[i] + i > f[mx] + mx) mx = i;
  };
}
int main() {
  gets(_a);
  gets(_b);
  string a(_a), b(_b);
  int n = ((int)((a).size()));
  if (((int)((b).size())) != n) {
    puts("-1 -1");
    return 0;
  };
  string fa(a), fb(b);
  for (int i = (0); i <= (n - 1); i++) b[i] = _b[n - i - 1];
  for (int i = (0); i <= (n - 1); i++) fa[i] = _a[n - i - 1];
  cal(fb + a, g1);
  cal(fa + fb, g2);
  for (int i = (0); i <= (n - 1); i++) g1[i] = g1[i + n];
  for (int i = (0); i <= (n - 1); i++) g2[i] = i - g2[2 * n - 1 - i];
  for (int i = (n - 2); i >= (0); i--) g2[i] = min(g2[i], g2[i + 1]);
  int x = -1, y = -1;
  g1[n] = 0;
  for (int i = (0); i <= (n - 2); i++)
    if (a[i] != b[i])
      break;
    else {
      int l = n - 1 - g1[i + 1], r = n - 1;
      if (g2[l] > i) continue;
      while (l < r) {
        int mid = (l + r + 1) >> 1;
        if (g2[mid] <= i)
          l = mid;
        else
          r = mid - 1;
      };
      if (g2[l] <= i) x = i, y = i + n - l;
    };
  printf("%d %d\n", x, y);
  return 0;
}
