#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6 + 10;
string rs;
int pre[maxn];
void matchprefix() {
  int n = rs.length();
  pre[0] = 0;
  int k = 0;
  for (int i = 1; i < n; i++) {
    while (k > 0 && rs[k] != rs[i]) k = pre[k - 1];
    if (rs[k] == rs[i]) k++;
    pre[i] = k;
  }
}
int z[maxn];
void Z_function() {
  int n = rs.length();
  z[0] = 0;
  int L = 0, R = 0;
  for (int i = 1; i < n; i++) {
    z[i] = 0;
    if (i <= R) {
      if (z[i - L] < R - i + 1)
        z[i] = z[i - L];
      else {
        z[i] = min(z[i - L], R - i + 1);
        while (i + z[i] < n && rs[i + z[i]] == rs[z[i]]) z[i]++;
        L = i;
        R = i + z[i] - 1;
      }
    } else {
      while (i + z[i] < n && rs[i + z[i]] == rs[z[i]]) z[i]++;
      L = i;
      R = i + z[i] - 1;
    }
  }
}
int main() {
  string s, t;
  getline(cin, s);
  getline(cin, t);
  int n = s.length();
  if (n != t.length()) {
    cout << "-1 -1";
    return 0;
  }
  rs = s;
  reverse(rs.begin(), rs.end());
  rs.push_back('\n');
  rs += t;
  matchprefix();
  rs = t + '\n' + s + '\n';
  Z_function();
  int ansi = -1, ansj = -1;
  for (int i = 0; i + 1 < n; i++) {
    if (s[i] != t[n - 1 - i]) break;
    int len_0_i = i + 1;
    int len_i_j = z[n + i + 2];
    int len_j_n = pre[n + n - i - 1];
    if (len_j_n > 0 && len_0_i + len_i_j + len_j_n >= n) {
      ansi = i;
      ansj = n - len_j_n;
    }
  }
  cout << ansi << " " << ansj;
  return 0;
}
