#include <bits/stdc++.h>
using namespace std;
char s[1000010], t[1000010];
const unsigned long long base = 19260817;
unsigned long long pre[1000010], h1[1000010], h2[1000010], h3[1000010],
    h4[1000010];
int n, m;
unsigned long long get(int l, int r, unsigned long long *h) {
  return h[r] - h[l - 1] * pre[r - l + 1];
}
int solve(int k, unsigned long long *h1, unsigned long long *h2) {
  int l = 1, r = n - k + 1, ans = 0;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (get(k, k + mid - 1, h1) == h2[mid])
      ans = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  return ans;
}
int tr[1000010];
void change(int k) {
  tr[k] = min(tr[k], k);
  for (int i = k; i <= n; i += (i & -i)) tr[i] = min(tr[i], k);
}
int get(int k) {
  int ans = 1e9;
  for (int i = k; i >= 1; i -= i & -i) ans = min(ans, tr[i]);
  return ans;
}
vector<int> vec[1000010];
int main() {
  memset(tr, 63, sizeof(tr));
  gets(s + 1);
  gets(t + 1);
  n = strlen(s + 1);
  m = strlen(t + 1);
  if (n != m) return puts("-1 -1"), 0;
  pre[0] = 1;
  for (int i = 1; i <= n; i++) pre[i] = pre[i - 1] * base;
  for (int i = 1; i <= n; i++) {
    h1[i] = h1[i - 1] * base + s[i] + 1;
    h2[i] = h2[i - 1] * base + t[i] + 1;
    h3[i] = h3[i - 1] * base + s[n - i + 1] + 1;
    h4[i] = h4[i - 1] * base + t[n - i + 1] + 1;
  }
  for (int i = 1; i <= n; i++) {
    int k = solve(i, h2, h3);
    if (k != 0) vec[i + k - 1].push_back(i);
  }
  int x = -1, y = -1;
  for (int i = 1; i <= n; i++) {
    if (h1[i - 1] != h4[i - 1]) continue;
    int k = n - i + 1, len = solve(i, h1, h2);
    for (int j = 0; j < vec[k].size(); j++) change(vec[k][j]);
    int t = get(len + 1);
    if (t <= n && i != 1 && i + t - 2 != n) x = i, y = x + t - 2;
    if (x > y) break;
  }
  if (x > y)
    x = n - 2, y = n - 1;
  else if (x != -1)
    x -= 2;
  printf("%d %d\n", x, y);
}
