#include <bits/stdc++.h>
using namespace std;
char a[1000005], b[1000005];
long long int p[1000005], ha[1000005], hb[1000005], ah[1000005];
long long int best[1000005];
void kill() {
  cout << -1 << " " << -1 << endl;
  exit(0);
}
long long int get(long long int num, long long int low) {
  return num * p[1000005 - low - 1];
}
int main() {
  gets(a);
  gets(b);
  long long int n = strlen(a);
  if (strlen(a) != strlen(b)) kill();
  p[0] = 1;
  for (long long int i = 1; i <= 1000005; i++) p[i] = p[i - 1] * 1007;
  for (long long int i = 1; i <= n; i++) ha[i] = ha[i - 1] + a[i - 1] * p[i];
  for (long long int i = 1; i <= n; i++) hb[i] = hb[i - 1] + b[i - 1] * p[i];
  for (long long int i = 1; i <= n; i++) ah[i] = ah[i - 1] + a[n - i] * p[i];
  long long int cnt = 0;
  for (long long int i = 0; i <= n; i++) {
    long long int low = 0, high = n - i + 1;
    while (low + 1 < high) {
      long long int mid = (low + high) / 2;
      if (get(hb[mid + i] - hb[i], i) == get(ah[mid], 0))
        low = mid;
      else
        high = mid;
    }
    while (cnt <= low + i) best[cnt++] = i;
  }
  long long int mini = (1ll << (long long int)(60)),
                maxi = (1ll << (long long int)(60));
  for (long long int i = 1; i < n; i++) {
    long long int least = best[n - i];
    if (a[i - 1] != b[n - i]) break;
    if (n <= least + i) continue;
    if (get(hb[least], 0) == get(ha[least + i] - ha[i], i)) {
      mini = i - 1;
      maxi = i + least;
    }
  }
  if (mini == (1ll << (long long int)(60))) kill();
  cout << mini << " " << maxi << endl;
}
