#include <bits/stdc++.h>
using namespace std;
int P[2000003], z[2000003], l1, l2, x, a1, sh1, sh2;
char s1[1000003], s2[1000003], s3[2000003], s4[2000003];
int main() {
  gets(s1);
  gets(s2);
  l1 = strlen(s1);
  l2 = strlen(s2);
  sh1 = sh2 = -1;
  if (l1 != l2) goto gx;
  for (int i = l1 - 1; i >= 0; i--) s3[l1 - 1 - i] = s1[i];
  s3[l1] = 1;
  for (int i = 0; i < l2; i++) s3[l1 + 1 + i] = s2[i];
  for (int i = 0; i < l2; i++) s4[i] = s2[i];
  s4[l2] = 1;
  for (int i = 0; i < l1; i++) s4[l2 + 1 + i] = s1[i];
  x = 0;
  for (int i = 1; i < l1 + l2 + 1; i++) {
    while (x && s3[x] != s3[i]) x = P[x - 1];
    if (s3[x] == s3[i]) P[i] = ++x;
  }
  x = 0;
  a1 = 0;
  for (int i = 1; i < l2 + l1 + 1; i++) {
    z[i] = min(max(x - i, 0), z[i - a1]);
    while (i + z[i] < l2 + l1 + 1 && s4[z[i]] == s4[i + z[i]]) z[i]++;
    if (i + z[i] - 1 > x) x = i + z[i] - 1, a1 = i;
  }
  for (int i = 0; i < l1; i++) {
    if (s1[i] != s2[l2 - 1 - i]) break;
    if (P[l2 + l1 - i - 1] && z[l2 + i + 2] + P[l2 + l1 - i - 1] + i >= l1 - 1)
      sh1 = i, sh2 = l1 - P[l2 + l1 - i - 1];
  }
gx:
  printf("%d %d\n", sh1, sh2);
  return 0;
}
