#include <bits/stdc++.h>
using namespace std;
vector<int> prefix_function(const string &s) {
  int n = (int)s.size();
  vector<int> p(n);
  p[0] = 0;
  for (int i = 1; i < n; i++) {
    p[i] = p[i - 1];
    while (p[i] > 0 && s[p[i]] != s[i]) p[i] = p[p[i] - 1];
    if (s[p[i]] == s[i]) p[i]++;
  }
  return p;
}
vector<int> Z_function(string s) {
  int n = (int)s.size();
  vector<int> Z(n);
  int l = 0, r = 0;
  for (int i = 1; i < n; i++) {
    if (i <= r) Z[i] = min(Z[i - l], r - i + 1);
    while (i + Z[i] < n && s[i + Z[i]] == s[Z[i]]) Z[i]++;
    if (i + Z[i] >= r) {
      l = i;
      r = i + Z[i] - 1;
    }
  }
  return Z;
}
int main() {
  string a;
  getline(cin, a);
  string b;
  getline(cin, b);
  int n = (int)a.size();
  if (n != (int)b.size()) {
    cout << "-1 -1" << endl;
    return 0;
  }
  vector<int> Z = Z_function(b + char(10) + a);
  reverse(a.begin(), a.end());
  vector<int> pi = prefix_function(a + char(10) + b);
  reverse(a.begin(), a.end());
  int i = 0;
  int x = -1;
  int y = -1;
  while (i < n - 1) {
    if (a[i] != b[n - i - 1]) break;
    if (i + Z[n + 1 + i + 1] + pi[2 * n - i - 1] + 1 >= n) {
      x = i;
      y = n - pi[2 * n - i - 1];
    };
    i++;
  }
  cout << x << " " << y << endl;
  return 0;
}
