require 'prime'

def key(n)
	qs = []
	Prime.each(Math.sqrt(n).to_i){|q|
		k = 0
		while n % q == 0 
			n /= q
			k += 1
		end
		qs << q if k > 0
	}
	qs << n if n > 1
	qs.pop - qs.inject(0, :+)
end

while gets
	a, b = $_.split.map &:to_i
	break if a == 0
	puts key(a) > key(b) ? ?a : ?b
end