const LIMIT: usize = 31; fn solve(factors: &Vec>) -> usize { let mut x = String::new(); std::io::stdin().read_line(&mut x).ok(); let x: usize = x.trim().parse().unwrap(); let mut target = x; let mut xfacts = vec![0usize; LIMIT+1]; for i in 2..=LIMIT { while target % i == 0 { target /= i; xfacts[i] += 1; } } for i in 2..=LIMIT { let mut tcnt = 1usize; let mut fcnt = 1usize; for j in 2..=LIMIT { if factors[i][j] == 0 { continue; } tcnt *= 1 + xfacts[j]; fcnt *= 1 + factors[i][j]; } if tcnt * 2 == fcnt { return x * i; } } LIMIT * x } fn main() { let mut t = String::new(); std::io::stdin().read_line(&mut t).ok(); let t: usize = t.trim().parse().unwrap(); let mut result = Vec::with_capacity(t); let mut factors = vec![vec![0usize; LIMIT+1]; LIMIT+1]; for i in 2..=LIMIT { let mut target = i; for j in 2..=LIMIT { while target % j == 0 { factors[i][j] += 1; target /= j; } } } for _ in 0..t { result.push(solve(&factors)); } for &v in result.iter() { println!("{}", v); } }