def comp(a, b)

	h0, w0 = a
	h1, w1 = b

	if h0**2 + w0**2 != h1**2 + w1**2
		h0**2 + w0**2 < h1**2 + w1**2
	else
		h0 < h1
	end

end

def solve(h, w)

	array = []

	(1..150).each do |x|
		((x+1)..150).each do |y|
			array.push([x,y])
		end
	end

	array.sort! { |a,b|
		if(comp(a,b))
			-1
		elsif(comp(b,a))
			1
		else
			0
		end
	}

	array.length.times do |i|
		if array[i] == [h,w]
			return array[i+1]
		end
	end

	return [-1, -1]

end

if __FILE__ == $0

	loop do
		h, w = STDIN.readline.split.map{|i|i.to_i}
		if h == 0
			break
		end
		ah, aw = solve(h, w)
		puts "#{ah} #{aw}"
	end

end