#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long inf = numeric_limits<long long>::max() / 2;
const long double eps = 1e-9;
const long double pi = acos(-1);
template <typename T>
inline bool mineq(T& a, T b) {
  return (a > b) ? (a = b, 1) : 0;
}
template <typename T>
inline bool maxeq(T& a, T b) {
  return (a < b) ? (a = b, 1) : 0;
}
inline void solve(), read();
const string file = "";
int main() {
  if (file != "") {
    freopen((file + ".in").c_str(), "r", stdin);
    freopen((file + ".out").c_str(), "w", stdout);
  }
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  read();
  solve();
  return 0;
}
long long n;
string a, b, ra;
vector<long long> p, z;
string s1, s2;
void prefix(string& s, vector<long long>& p) {
  long long n = (long long)((s).size());
  p.resize(n);
  p[0] = 0;
  for (long long i = 1; i < n; i++) {
    long long j = p[i - 1];
    while (j && s[i] != s[j]) {
      j = p[j - 1];
    }
    if (s[i] == s[j]) {
      ++j;
    }
    p[i] = j;
  }
}
void zet(string& s, vector<long long>& z) {
  long long n = (long long)((s).size());
  z.resize(n);
  z[0] = 0;
  long long l = -1, r = -1;
  for (long long i = 1; i < n; i++) {
    z[i] = 0;
    if (i < r) {
      z[i] = min(r - i, z[i - l]);
    }
    while (i + z[i] < (long long)((s).size()) && s[z[i]] == s[i + z[i]]) {
      ++z[i];
    }
    if (i + z[i] > r) {
      r = i + z[i];
      l = i;
    }
  }
}
inline void solve() {
  string s1 = ra + '\127' + b;
  prefix(s1, p);
  string s2 = b + '\127' + a;
  zet(s2, z);
  long long I = -1, J = -1;
  for (long long i = 0; i < n; i++) {
    if (a[i] != b[n - 1 - i]) {
      break;
    }
    long long j = n - p[2 * n - i - 1];
    if (n + 2 + i < (long long)((z).size()) && z[n + 2 + i] >= j - i - 1) {
      I = i, J = j;
    }
  }
  cout << I << " " << J << "\n";
}
inline void read() {
  getline(cin, a);
  getline(cin, b);
  if ((long long)((a).size()) != (long long)((b).size())) {
    cout << -1 << " " << -1 << "\n";
    exit(0);
  }
  n = (long long)((a).size());
  ra = a;
  reverse((ra).begin(), (ra).end());
}
