#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 256;
const char nxt = '\n';
inline void in(string Q) {
  Q += ".in";
  freopen(Q.c_str(), "r", stdin);
}
inline void out(string Q) {
  Q += ".out";
  freopen(Q.c_str(), "w", stdout);
}
inline void open_file(string Q) {
  in(Q);
  out(Q);
}
inline bool Pal(const string& s) {
  return equal(s.begin(), s.end(), s.rbegin());
}
unsigned long long h[5][MAXN], pw[MAXN], p = 991;
string s, k;
inline unsigned long long get(int type, int l, int r, int len) {
  if (type % 2 == 0) {
    if (!l) return h[type][r];
    return h[type][r] - pw[r - l + 1] * h[type][l - 1];
  } else {
    int L = l;
    l = len - r - 1;
    r = len - L - 1;
    if (!l) return h[type][r];
    return h[type][r] - pw[r - l + 1] * h[type][l - 1];
  }
}
inline int lcp(int L, int R) {
  int l = 1, r = R - L + 2;
  if (s[L] != k[0]) return 0;
  while (r - l > 1) {
    int mid = (l + r) >> 1;
    if (L + mid - 1 <= R &&
        get(0, L, L + mid - 1, -1) == get(2, 0, mid - 1, -1))
      l = mid;
    else
      r = mid;
  }
  if (L + r - 1 <= R && get(0, L, L + r - 1, -1) == get(2, 0, r - 1, -1)) l = r;
  return l;
}
inline void hashing() {
  pw[0] = 1;
  for (int i = 1; i <= (int)1e6; ++i) {
    pw[i] = pw[i - 1] * p;
  }
  h[0][0] = s[0] - 31;
  for (int i = 1; i < int(s.size()); ++i) {
    h[0][i] = h[0][i - 1] * p + s[i] - 31;
  }
  h[2][0] = k[0] - 31;
  for (int i = 1; i < int(k.size()); ++i) {
    h[2][i] = h[2][i - 1] * p + k[i] - 31;
  }
  reverse(s.begin(), s.end());
  reverse(k.begin(), k.end());
  h[1][0] = s[0] - 31;
  for (int i = 1; i < int(s.size()); ++i) {
    h[1][i] = h[1][i - 1] * p + s[i] - 31;
  }
  h[3][0] = k[0] - 31;
  for (int i = 1; i < int(k.size()); ++i) {
    h[3][i] = h[3][i - 1] * p + k[i] - 31;
  }
  reverse(s.begin(), s.end());
  reverse(k.begin(), k.end());
}
bool check(int l, int r) {
  unsigned long long h1 = 0;
  if (r >= l) {
    h1 = get(0, l, r, -1);
  } else if (r + 1 < int(s.size())) {
    h1 = get(1, r + 1, int(s.size()) - 1, int(s.size()));
  } else {
    h1 = get(1, 0, l - 1, int(s.size()));
    return h1 == h[2][int(k.size()) - 1];
  }
  if (r + 1 < int(s.size()) && r >= l)
    h1 = h1 * pw[int(s.size()) - (r + 1)] +
         get(1, r + 1, int(s.size()) - 1, int(s.size()));
  h1 = h1 * pw[l] + get(1, 0, l - 1, int(s.size()));
  return h1 == h[2][int(k.size()) - 1];
}
int I = -1, J = -1;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  if (0) open_file("");
  getline(cin, s);
  getline(cin, k);
  if (int(s.size()) != int(k.size())) {
    cout << "-1 -1";
    return 0;
  }
  hashing();
  for (int i = 1; i < int(s.size()); ++i) {
    int Len = lcp(i, int(s.size()) - 1);
    if (check(i, i + Len - 1)) {
      I = i - 1, J = i + Len;
    }
    if (check(i, i - 1)) {
      I = i - 1, J = i;
    }
  }
  for (int i = I + 1; i < J - 1; ++i) {
    if (check(I + 1, i)) {
      J = i + 1;
      break;
    }
  }
  cout << I << ' ' << J << nxt;
  return 0;
}
