#include <bits/stdc++.h>
using namespace std;
char s1[2222222], s2[2222222], st[2222222];
int f[2222222], t[2222222], g[2222222], z[2222222], n;
inline void calc_z(int n) {
  memset(z, 0, sizeof(z));
  for (int i = 1, l = 0, r = 0; i < n; ++i) {
    if (i <= r) z[i] = min(r - i + 1, z[i - l]);
    while (i + z[i] < n and st[z[i]] == st[i + z[i]]) ++z[i];
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
  }
}
inline void gf() {
  memcpy(st, s2, n);
  st[n] = 1;
  memcpy(st + n + 1, s1, n);
  calc_z(n + n + 1);
  for (int i = 0; i < n; ++i) f[i] = z[n + i + 1];
}
inline void gt() {
  memcpy(st, s1, n);
  reverse(st, st + n);
  st[n] = 1;
  memcpy(st + n + 1, s2, n);
  calc_z(n + n + 1);
  for (int i = 0; i < n; ++i) t[i] = z[n + i + 1];
}
pair<int, int> q[2222222];
int qa, qb;
inline void gg() {
  for (int i = 0; i <= n; ++i) {
    int b = i + t[i];
    while (qa < qb and q[qa].second < i) ++qa;
    if (qb == qa or b > q[qb - 1].second) q[qb++] = make_pair(i, b);
    g[i] = i - q[qa].first;
  }
}
int main() {
  gets(s1), gets(s2), n = strlen(s1);
  if (strlen(s2) != n) {
    puts("-1 -1");
    exit(0);
  }
  gf(), gt(), gg();
  pair<int, int> ans = make_pair(-1, 1);
  for (int i = 1; i < n; ++i) {
    if (s2[n - i] != s1[i - 1]) break;
    if (g[n - i] > 0 and f[i] + g[n - i] >= n - i)
      ans = max(ans, make_pair(i - 1, g[n - i] - n));
  }
  printf("%d %d", ans.first, -ans.second);
  return 0;
}
