#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T& s) {
  s = 0;
  int f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    s = s * 10 + c - '0';
    c = getchar();
  }
  s *= f;
}
void exkmp(char* s, char* t, int n, int m, int* f, int* g) {
  int mx = 0;
  f[1] = n;
  for (int i = 2; i <= m; i++) {
    f[i] = max(0, min(mx + f[mx] - i, f[i - mx + 1]));
    while (i + f[i] <= m && t[i + f[i]] == t[f[i] + 1]) f[i]++;
    if (i + f[i] > mx + f[mx]) mx = i;
  }
  mx = 0;
  for (int i = 1; i <= n; i++) {
    g[i] = max(0, min(f[i - mx + 1], mx + g[mx] - i));
    while (i + g[i] <= n && s[i + g[i]] == t[g[i] + 1]) g[i]++;
    if (i + g[i] > mx + g[mx]) mx = i;
  }
}
int n, m;
char a[1000005], b[1000005], at[1000005];
int f[1000005], g1[1000005], g2[1000005];
int mxw[1000005];
int main() {
  n = m = 1;
  char c = getchar();
  while (c != '\n') {
    a[n++] = c;
    c = getchar();
  }
  c = getchar();
  while (c != '\n') {
    b[m++] = c;
    c = getchar();
  }
  n--;
  m--;
  if (n != m) {
    printf("-1 -1\n");
    return 0;
  }
  if (a[1] != b[n]) {
    printf("-1 -1\n");
    return 0;
  }
  int mxi = 1;
  for (mxi; mxi < n && a[mxi + 1] == b[n - mxi]; mxi++)
    ;
  for (int i = 1; i <= m; i++) at[i] = a[m + 1 - i];
  exkmp(a, b, n, m, f, g1);
  exkmp(b, at, n, m, f, g2);
  memset(mxw, 23, sizeof(mxw));
  for (int i = 1; i <= n; i++)
    mxw[1 + n - g2[i] - i] = min(mxw[1 + n - g2[i] - i], i);
  for (int i = 1; i <= n; i++) mxw[i] = min(mxw[i], mxw[i - 1]);
  for (int i = mxi; i >= 1; i--) {
    int mx = min(g1[i + 1] + 1, n - i);
    int gg = mxw[i];
    if (gg > mx) continue;
    printf("%d %d\n", i - 1, gg + i - 1);
    return 0;
  }
  printf("-1 -1\n");
  return 0;
}
