#include <fstream>
#include <string>
#include <vector>
#include <sstream>

using namespace std;

int main() {
  ifstream fin("password.in");
  ofstream fout("password.out");

  string a, b;
  fin >> a >> b;
  vector <int> sum(a.size());
  for (int i = 0; i < (int)a.size(); i++) {
    sum[i] = (a[i] - '0') + (i ? sum[i - 1] : 0);
  }
  int maxPref = 0;
  while (maxPref < (int)a.size() && maxPref < (int)b.size() && a[maxPref] == b[maxPref]) {
    maxPref++;
  }
  int maxSuff = 0;
  while (maxSuff < (int)a.size() && maxSuff < (int)b.size() && a[a.size() - 1 - maxSuff] == b[b.size() - 1 - maxSuff]) {
    maxSuff++;
  }
  for (int l = 0; l < (int)b.size(); l++) {
    string tb;
    for (int r = l; r < (int)b.size() && r <= l + 10; r++) {
      tb += b[r];
      int la = l, ra = r + (int)a.size() - (int)b.size();
      if (maxPref >= l && maxSuff >= (int)b.size() - 1 - r && la <= ra && ra < (int)a.size()) {
        int sa = sum[ra] - (la ? sum[la] : 0);
        stringstream ss;
        ss << sa;
        string ta;
        ss >> ta;
        if (tb == ta) {
          fout << (l + 1) << " " << (r + 1) << endl;
          return 0;
        }
      }
    }
  }

  return -1;
}
