#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int n;
int f[N], g[N], h[N];
char a[N], _a[N], b[N];
string A, B;
void work(char a[], char b[], int f[]) {
  memset(h, 0, sizeof h);
  h[1] = 0;
  int j = 1;
  for (int i = 2; i <= n; ++i) {
    if (j + h[j] >= i) h[i] = h[i - j + 1];
    while (a[i + h[i]] == a[1 + h[i]]) ++h[i];
    --h[i];
    if (i + h[i] > j + h[j]) j = i;
  }
  f[1] = 0;
  j = 1;
  for (int i = 2; i <= n; ++i) {
    if (j + f[j] >= i) f[i] = max(0, min(j + f[j] - i, h[i - j + 1]));
    while (b[i + f[i]] == a[1 + f[i]]) ++f[i];
    --f[i];
    if (i + f[i] >= j + f[j]) j = i;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  getline(cin, A);
  getline(cin, B);
  if (((int)A.size()) < 2 || ((int)A.size()) != ((int)B.size())) {
    puts("-1 -1");
    return 0;
  }
  n = ((int)A.size());
  for (int i = 1; i <= n; ++i) a[i] = A[i - 1], b[i] = B[i - 1];
  a[0] = b[0] = _a[0] = (char)0;
  for (int i = 1; i <= n; ++i) _a[i] = a[n - i + 1];
  a[n + 1] = _a[n + 1] = b[n + 1] = (char)0;
  work(b, a, f);
  for (int i = 2; i <= n; ++i) ++f[i];
  work(_a, b, g);
  for (int i = 1; i < n; ++i) g[i] = i + 1 + g[i + 1];
  int _i = n;
  while (_a[_i] == b[_i] && _i) --_i;
  if (!_i) {
    printf("%d %d\n", n - 2, n - 1);
    return 0;
  }
  int o = 0;
  for (++_i; _i <= n; ++_i) {
    int i = n - _i + 1;
    if (f[i + 1] <= o) continue;
    for (int j = o + 1; j <= f[i + 1]; ++j)
      if (g[j] >= _i - 1) {
        printf("%d %d\n", i - 1, n - _i + min(j, _i - 1) + 1);
        return 0;
      }
    o = f[i + 1];
  }
  puts("-1 -1");
  return 0;
}
