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?(n, f0, f1) y = n f1.each{|k, v| if f0.include?(k) z = f0[k] y = y / (z+1) * (z+v+1) else y *= v + 1 end } n * 2 == y end T = gets.to_i X = [] T.times { X << gets.to_i } ans = [] X.each {|x| f = prime_factor(x) n = f.values.inject(1) {|product, i| product * (i + 1)} i = 2 while not multiple?(n, f, prime_factor(i)) do i += 1 end ans << x * i } puts ans