#!/usr/bin/python3

import sys
sys.stdin = open("password.in", "r");
sys.stdout = open("password.out", "w");
s = sys.stdin.readline().split()[0]; slen = len(s)
t = sys.stdin.readline().split()[0]; tlen = len(t)

psum = [ 0 for i in range(max(slen, tlen) + 1) ] 
eqpref = [0 for i in range(max(slen, tlen) + 1) ]
eqsuff = [0 for i in range(max(slen, tlen) + 1) ]

eqpref[0] = True
eqsuff[0] = True

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

def request(l, r):
	if l == 0: 
		return psum[r]
	else:
		return psum[r] - psum[l - 1]


for i in range(1, min(slen, tlen) + 1):
	eqpref[i] = eqpref[i - 1] and s[i - 1] == t[i - 1]

for i in range(1, min(slen, tlen) + 1):
	eqsuff[i] = eqsuff[i - 1] and s[slen - i] == t[tlen - i]	

for i in range(0, tlen):
	curnumber = 0
	for j in range(i, min(i + 8, 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 eqpref[i] and eqsuff[tlen - i - (j - i + 1)] and (curnumber == request(si, sj)):
			print(si + 1, sj + 1)
			exit(0)
print('-1 -1')

