#include <bits/stdc++.h>
void read(int &x) {
  x = 0;
  int flag = 1;
  char ch = ' ';
  while (ch < '0' || ch > '9') {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x *= flag;
}
void read(long long &x) {
  x = 0;
  int flag = 1;
  char ch = ' ';
  while (ch < '0' || ch > '9') {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x *= flag;
}
using namespace std;
const int maxn = 1000010, base = 257;
char a[maxn], b[maxn], s[maxn * 2];
int nxt[maxn * 2];
unsigned long long ha[maxn], hb[maxn], power[maxn];
unsigned long long get_a(int a, int b) {
  return ha[b] - ha[a - 1] * power[b - a + 1];
}
unsigned long long get_b(int a, int b) {
  return hb[b] - hb[a - 1] * power[b - a + 1];
}
int main() {
  gets(a + 1), gets(b + 1);
  int n = strlen(a + 1);
  if (n != strlen(b + 1)) {
    puts("-1 -1");
    return 0;
  }
  for (int i = 1; i <= (int)n; i++) s[i] = a[n - i + 1];
  s[n + 1] = 31;
  for (int i = n + 2; i <= (int)n + n + 1; i++) s[i] = b[i - n - 1];
  nxt[1] = 0;
  for (int i = 2, j = 0; i <= n + n + 1; i++) {
    while (j && s[j + 1] != s[i]) j = nxt[j];
    if (s[j + 1] == s[i]) j++;
    nxt[i] = j;
  }
  power[0] = 1;
  for (int i = 1; i <= (int)n; i++)
    power[i] = power[i - 1] * base, ha[i] = ha[i - 1] * base + a[i],
    hb[i] = hb[i - 1] * base + b[i];
  int ri = 0, rj = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] != b[n - i + 1]) break;
    int j = n - nxt[2 * n - i + 1] + 1;
    if (get_a(i + 1, j - 1) == get_b(1, j - i - 1)) ri = i, rj = j;
  }
  printf("%d %d\n", ri - 1, rj - 1);
  return 0;
}
