#前計算をしておく
$hw_dict = []
def init_dict()
	for w in (1..151)
		for h in (1...w)
			elm = [h*h+w*w,h,w]
			$hw_dict.push(elm)
		end
	end
	$hw_dict = $hw_dict.sort()
end

def pred_pair(p1,p2)
	if p1[0] < p2[0]
		1
	elsif p1[0] > p2[0]
		-1
	else
		if p1[1] < p2[1]
			1
		elsif p1[1] > p2[1]
			-1
		else
			0
		end
	end
end


def solve(h,w)
	l = 0
	r = $hw_dict.length() - 1
	p = [h*h+w*w,h,w]
	ansp = 0
	found = 0
	while r - l > 1
		m = (l + r) / 2
		if pred_pair(p,$hw_dict[m]) > 0
			r = m
		elsif pred_pair(p,$hw_dict[m]) < 0
			l = m
		else
			ansp = m + 1
			found = 1
			break
		end
	end
	if found == 0
		ansp = r
	end
	[$hw_dict[ansp][1],$hw_dict[ansp][2]]
end

init_dict()

while nums = STDIN.gets().chomp().split(" ")
	if nums[0].to_i() == 0 && nums[1].to_i() == 0
		exit
	else
		ans = solve(nums[0].to_i(),nums[1].to_i())
		puts "#{ans[0]} #{ans[1]}"
	end
end