#http://simanman.hatenablog.com/entry/2013/06/24/200306
#10/27

data = Array.new()
number = Array.new()


	while data = gets do
		number.push(data.split(" "))
	end


j = 0

for i in number 
	 number[j] = i.map(&:to_i)
	 j += 1
end

common = Array.new().map{[]}

k = 0
h = 0

for i in number
	for j in number[h]
		for tmp in 1 .. j
			if(j%tmp == 0)
				if(tmp == 1)
					common.push([])
				end
				common[k].push(tmp)
			end
		end
		k += 1
	end
	h += 1
end

#p common

 
result = Array.new()

1.step(k , 2){|l|
	p ((common[l-1]&common[l]).max)
}
=begin
a = Array.new().map{[]}

p a
(a.push([]))[0].push(1)
a[0].push(2)
p a
=end