#!/usr/bin/python3

import sys
sys.stdin = open("password.in", "r");
sys.stdout = open("password.out", "w");
s,t = sys.stdin.read().split()
slen, tlen = map(len, (s,t))

psum = [0] * slen
psum[0] = ord(s[0]) - ord('0')

for i in range(1, slen):
	psum[i] = psum[i - 1] + ord(s[i]) - ord('0')

request = lambda l, r: psum[r] if l == 0 else psum[r] - psum[l - 1]

eqpref, eqsuff = 0, 0

while eqpref < min(slen, tlen) and s[eqpref] == t[eqpref]: eqpref += 1
while eqsuff < min(slen, tlen) and s[slen - eqsuff - 1] == t[tlen - eqsuff - 1]: eqsuff += 1
       
for i in range(0, tlen):
	curnumber = 0
	for j in range(i, min(i + 6, tlen)):
		curnumber = curnumber * 10 + ord(t[j]) - ord('0')
		si = i
		sj = slen - tlen + j
		if si > sj: continue
		if ((t[i] != '0') or (i == j)) and i <= eqpref and (tlen - i - (j - i + 1)) <= eqsuff and (curnumber == request(si, sj)):
			print(si + 1, sj + 1)
			exit(0)
print('-1 -1')

