PRIMES = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31] def count(x, p) c = 0 while x % p == 0 x //= p c += 1 end c end read_line.to_i.times do x = read_line.to_i64 divisor_count = PRIMES.reduce(1) { |acc, p| acc * count(x, p).succ } puts x * (2..).find { |k| divisor_count * 2 == PRIMES.reduce(1) { |acc, p| acc * (count(x, p) + count(k, p) + 1) } }.not_nil! end