def comp( y1, x1, y2, x2 )
	if y1 * y1 + x1 * x1 != y2 * y2 + x2 * x2
		y1 * y1 + x1 * x1 < y2 * y2 + x2 * x2 ? [ y1, x1 ] : [ y2, x2 ]
	else
		y1 < y2 ? [ y1, x1 ] : [ y2, x2 ]
	end
end


while ( h, w = gets.strip.split.map( &:to_i ) ) != [ 0, 0 ]
	rh = rw = 150
	for y in 1..150
		for x in y + 1 ..150
			if ( h != y || w != x ) && [ h, w ] == comp( h, w, y, x )
				rh, rw = comp( rh, rw, y, x )
			end
		end
	end

	print rh, " ", rw, "\n"
end