#include <bits/stdc++.h>
using namespace std;
int n;
string a, b;
vector<int> z_function(string s) {
  int n = s.size();
  vector<int> z(n);
  for (int i = 1, l = 0, r = 0; i < n; ++i) {
    if (i <= r) z[i] = min(r - i + 1, z[i - l]);
    while (i + z[i] < n && s[z[i]] == s[i + z[i]]) ++z[i];
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
  }
  return z;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  getline(cin, a);
  getline(cin, b);
  string rb = b, ra = a;
  reverse(ra.begin(), ra.end());
  reverse(rb.begin(), rb.end());
  n = a.size();
  if (n != b.size() or n < 2) {
    cout << "-1 -1";
    return 0;
  }
  vector<int> zba = z_function(b + a);
  vector<int> zrab = z_function(ra + b);
  int ansi = -1, ansj;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] != rb[i]) break;
    int j = zba[i + n + 1];
    if (zrab[j + n] + j + i + 1 >= n) {
      ansi = i;
    }
  }
  if (ansi == -1) {
    cout << "-1 -1";
    return 0;
  }
  for (int j = zba[ansi + n + 1]; j >= 0; j--) {
    if (zrab[j + n] + j + ansi + 1 >= n) {
      ansj = j + ansi + 1;
    }
  }
  cout << ansi << " " << ansj << endl;
}
