#include <iostream>
#include <fstream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <queue>
#include <list>
#include <cstring>

#define all(x) (x).begin(),(x).end()

using namespace std;

const int nmax = 2e6;

char s[nmax];
char t[nmax];
int prefsums[nmax];
int prefsumt[nmax];

bool equal_prefix[nmax];
bool equal_suffix[nmax];

int ssize;
int tsize;

int request(int l, int r)
{
	if (l == 0) 
		return prefsums[r];
	return prefsums[r] - prefsums[l - 1];
};

int main()
{
	freopen("password.in", "r", stdin);
	freopen("password.out", "w", stdout);
	gets(s);
	gets(t);
	ssize = strlen(s);
	tsize = strlen(t);

	prefsums[0] = s[0] - '0';
	prefsumt[0] = t[0] - '0';

	for (int i = 1; i < ssize; i ++)
		prefsums[i] = prefsums[i - 1] + s[i] - '0';
	for (int i = 1; i < tsize; i ++)
		prefsumt[i] = prefsumt[i - 1] + t[i] - '0';

	equal_prefix[0] = true;
	equal_suffix[0] = true; 

	for (int i = 1; i <= ssize && i <= tsize; i ++)
		equal_prefix[i] = equal_prefix[i - 1] && (s[i - 1] == t[i - 1]);

	for (int i = 1; i <= ssize && i <= tsize; i ++)
		equal_suffix[i] = equal_suffix[i - 1] && (s[ssize - i] == t[tsize - i]);

	for (int i = 0; i < tsize; i ++)
	{
		int curnumber = 0;
		for (int j = i; j < tsize && j < i + 8; j ++)
		{
			curnumber = 10 * curnumber + (t[j] - '0');
			int si = i;
			int sj = ssize - tsize + j;
			if (si > sj)
				continue;
			if ((t[i] != '0' || i == j) && equal_prefix[i] && equal_suffix[tsize - i - (j - i + 1)] && curnumber == request(si, sj))
			{
				cout << si + 1 << " " << sj + 1 << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
};
