#include <bits/stdc++.h>
using namespace std;
char a[1000006], b[1000006];
int z[1000006], p[1000006], pp[1000006];
unsigned long long hasha1[1000006], hashb1[1000006];
unsigned long long hasha2[1000006], hashb2[1000006];
unsigned long long base1 = 1e9 + 7, base2 = 257;
unsigned long long cs1[1000006], cs2[1000006];
int zz(int s, int n) {
  if (a[s] != b[1]) return 0;
  int low = 1, high = n - s + 1;
  while (low < high) {
    int mid = (low + high + 1) >> 1;
    if (((hasha1[s + mid - 1] - hasha1[s - 1]) == hashb1[mid] * cs1[s - 1]) &&
        ((hasha2[s + mid - 1] - hasha2[s - 1]) == hashb2[mid] * cs2[s - 1]))
      low = mid;
    else
      high = mid - 1;
  }
  return low;
}
int main() {
  gets(a + 1);
  gets(b + 1);
  int l = -1, h = -1;
  int n = strlen(a + 1);
  if (n != strlen(b + 1)) {
    printf("-1 -1\n");
    return 0;
  }
  cs1[0] = cs2[0] = 1;
  for (int i = 1; i <= n; i++) {
    hasha1[i] = hasha1[i - 1] + cs1[i - 1] * a[i];
    hashb1[i] = hashb1[i - 1] + cs1[i - 1] * b[i];
    cs1[i] = base1 * cs1[i - 1];
    hasha2[i] = hasha2[i - 1] + cs2[i - 1] * a[i];
    hashb2[i] = hashb2[i - 1] + cs2[i - 1] * b[i];
    cs2[i] = base2 * cs2[i - 1];
  }
  p[1] = 0;
  for (int i = 2, k; i <= n; i++) {
    for (k = p[i - 1]; k > 0 && a[n + 1 - i] != a[n - k]; k = p[k])
      ;
    p[i] = k + (a[n + 1 - i] == a[n - k]);
  }
  for (int i = 1, k; i <= n; i++) {
    for (k = pp[i - 1]; k > 0 && b[i] != a[n - k]; k = p[k])
      ;
    pp[i] = k + (b[i] == a[n - k]);
  }
  int ii = -1, jj = -1;
  for (int i = 1; i < n; i++)
    if (a[i] == b[n + 1 - i]) {
      if (pp[n - i] + zz(i + 1, n) >= n - i) {
        ii = i - 1;
        jj = n - pp[n - i];
      }
    } else
      break;
  cout << ii << " " << jj << endl;
  return 0;
}
