def prime_factor(n) res = Hash.new(0) i = 2 while i * i <= n do while n % i == 0 do res[i] += 1 n /= i end i += 1 end res[n] += 1 if n != 1 res end def prime?(n) i = 2 while i * i <= n do return false if n % i == 0 i += 1 end n != 1 end def multiple?(f0, f1) x = y = 1 f0.each{|k, v| x *= (v + 1) y *= (f1.include?(k) ? v + f1[k] + 1 : v + 1) } f1.each{|k, v| y *= v + 1 if not f0.include?(k) } x * 2 == y end T = gets.to_i X = [] T.times { X << gets.to_i } ans = [] X.each {|x| f = prime_factor(x) i = 2 while not multiple?(f, prime_factor(i)) do i += 1 end ans << x * i } puts ans