#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000006;
string A, a, b;
int h1[MAXN], h2[MAXN], pw[MAXN];
int f1[MAXN], f2[MAXN];
void Hash() {
  pw[0] = 1;
  for (int i = 1; i < MAXN; i++) {
    pw[i] = pw[i - 1] * 257;
  }
  h1[0] = A[0];
  h2[0] = b[0];
  for (int i = 1; i < A.size(); i++) {
    h1[i] = h1[i - 1] * 257 + A[i];
  }
  for (int i = 1; i < b.size(); i++) {
    h2[i] = h2[i - 1] * 257 + b[i];
  }
}
void KMP() {
  for (int i = 1, j = 0; i < a.size(); i++) {
    while (j && a[i] != a[j]) j = f1[j - 1];
    if (a[i] == a[j]) f1[i] = ++j;
  }
  for (int i = 0, j = 0; i < b.size(); i++) {
    while (j && b[i] != a[j]) j = f1[j - 1];
    if (b[i] == a[j]) j++;
    f2[i] = j;
  }
}
bool check(int i, int j) {
  if (i > j) return true;
  if (i == 0)
    return h1[j] == h2[j - i];
  else {
    return (h1[j] - h1[i - 1] * pw[j - i + 1]) == h2[j - i];
  }
}
int main() {
  ios::sync_with_stdio(false);
  getline(cin, A);
  getline(cin, b);
  a = A;
  if (A.length() != b.length()) {
    cout << -1 << ' ' << -1 << "\n";
    exit(0);
  }
  reverse(a.begin(), a.end());
  KMP();
  Hash();
  int ansI = 0, ansJ = 0;
  int chk = 0;
  for (int i = 0; i < A.size(); i++) {
    if (A[i] != b[A.size() - i - 1]) break;
    int overlap = f2[b.size() - i - 2];
    if (overlap && check(i + 1, A.size() - overlap - 1)) {
      ansI = i;
      ansJ = A.size() - overlap - 1;
      chk = 1;
    }
  }
  if (chk)
    cout << ansI << ' ' << ansJ + 1;
  else
    cout << -1 << ' ' << -1;
  return 0;
}
