{$H+}
const maxN = 2000000;
type integer=longint;
var s,t: string;
var prefsums: array[0..maxN] of integer;
	equal_prefix: array[0..maxN] of boolean;
	equal_suffix: array[0..maxN] of boolean;
	ssize, tsize, si, sj, i, j: integer;
	curnumber: integer;

function request(l,r: integer): integer;
begin
	if l = 0 then 
		request := prefsums[r]
	else
		request := prefsums[r] - prefsums[l - 1];
end;

function min(a,b : integer): integer;
begin
	if (a > b) then 
		min := b
	else
		min := a;
end;
	
begin
	assign(input, 'password.in');
	reset(input);
	assign(output, 'password.out');
	rewrite(output);
	readln(s);
	readln(t);
	ssize := length(s);
	tsize := length(t);

	prefsums[0] := 0;

	for i := 1 to ssize do
	begin
		prefsums[i] := prefsums[i - 1] + ord(s[i]) - ord('0');
	end;

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

	for i := 1 to min(ssize, tsize) do 
		equal_prefix[i] := equal_prefix[i - 1] and (s[i] = t[i]);

	for i := 1 to min(ssize, tsize) do 
		equal_suffix[i] := equal_suffix[i - 1] and (s[ssize - i + 1] = t[tsize - i + 1]);

	for i := 1 to tsize do 
	begin
		curnumber := 0;
		for j := i to min(i + 8, tsize) do
		begin
			curnumber := curnumber * 10 + ord(t[j]) - ord('0');
			si := i;
			sj := ssize - tsize + j;
			if si > sj then continue;
			if (s[1] <> '0' or i = j) and equal_prefix[i - 1] and equal_suffix[tsize - (i - 1) - (j - i + 1)] and (curnumber = request(si, sj)) then
			begin
				writeln(si, ' ', sj);
				exit;
			end;
		end;
	end;
	writeln(-1, ' ', -1);
end.

