#include <bits/stdc++.h>
using namespace std;
vector<int> prefix_function(string s) {
  int n = (int)s.length();
  vector<int> pi(n);
  for (int i = 1; i < n; ++i) {
    int j = pi[i - 1];
    while (j > 0 && s[i] != s[j]) j = pi[j - 1];
    if (s[i] == s[j]) ++j;
    pi[i] = j;
  }
  return pi;
}
vector<int> z_function(string s) {
  int n = (int)s.length();
  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() {
  string a, b;
  getline(cin, a);
  getline(cin, b);
  if (a.length() != b.length()) {
    cout << -1 << ' ' << -1;
    return 0;
  }
  int n = a.length();
  string s1 = a, s2 = b + '\0' + a;
  reverse(s1.begin(), s1.end());
  s1 += '\0' + b;
  vector<int> p = prefix_function(s1);
  vector<int> z = z_function(s2);
  int r_i = -1, r_j = -1;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] != b[n - i - 1]) break;
    int len = p[2 * n - i - 1];
    if (z[n + i + 2] >= n - i - len - 1) r_i = i, r_j = n - len;
  }
  cout << r_i << ' ' << r_j;
  return 0;
}
