#include <bits/stdc++.h>
using namespace std;
string a, b, aa, bb, ss;
int al, bl, p;
const int maxn = 2e6 + 100;
int z1[maxn], z2[maxn];
int can[maxn];
int maxi = -1, minj = -1;
void z_function(string &x, int *z) {
  int xl = x.length();
  int l = 1, r = -1;
  for (int i = 1; i < xl; i++) {
    if (i > r) {
      l = i, r = i - 1;
      while (x[r + 1] == x[r + 1 - i]) r++;
      z[i] = r - i + 1;
    } else if (z[i - l] + i - 1 < r)
      z[i] = z[i - l];
    else {
      l = i;
      while (x[r + 1] == x[r + 1 - i]) r++;
      z[i] = r - i + 1;
    }
  }
}
void myinit() {
  getline(cin, a);
  getline(cin, b);
  al = a.length(), bl = b.length();
  aa = a;
  reverse(aa.begin(), aa.end());
  bb = b;
  reverse(bb.begin(), bb.end());
  ss = b + "#" + a;
  z_function(ss, z1);
  ss = aa + "#" + b;
  z_function(ss, z2);
  int sl = ss.length();
  int k = b.length() - 1;
  memset(can, 0x3f, sizeof(can));
  for (int i = 0; i < b.length() - 1; i++) {
    if (k + i >= b.length() - 1) k--;
    while ((k + z2[i + b.length() + 1] >= b.length() - i - 1) && (k >= 0))
      can[k--] = i;
  }
}
void solve() {
  myinit();
  if ((a.length() != b.length()) || (a[0] != b[b.length() - 1])) return;
  for (int i = 0; i < b.length() - 1; i++) {
    if (a[i] != b[b.length() - i - 1]) break;
    if (can[i] <= z1[i + bl + 2]) {
      maxi = i;
      minj = maxi + can[i] + 1;
    }
  }
}
int main() {
  solve();
  cout << maxi << ' ' << minj << endl;
  return 0;
}
