import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { static List primes = new ArrayList<>(); static List squares = new ArrayList<>(); static List cubes = new ArrayList<>(); public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); boolean[] isNotPrimes = new boolean[100000]; for (int i = 2; i < isNotPrimes.length; i++) { if (!isNotPrimes[i]) { primes.add(i); squares.add((long)i * i); cubes.add((long)i * i * i); } } int q = sc.nextInt(); String result = IntStream.range(0, q).mapToObj(i -> is429(sc.nextLong()) ? "Yes" : "No") .collect(Collectors.joining("\n")); System.out.println(result); } static boolean is429(long x) { for (int i = 0; i < primes.size() && cubes.get(i) <= x; i++) { if (x % primes.get(i) == 0 ) { return isDouble(i, x / primes.get(i)); } } return false; } static boolean isDouble(int idx, long x) { for (int i = idx; i < primes.size() && squares.get(i) <= x; i++) { if (x % primes.get(i) == 0) { return isPrime(i, x / primes.get(i)); } } return false; } static boolean isPrime(int idx, long x) { for (int i = idx; i < primes.size() && squares.get(i) <= x; i++) { if (x % primes.get(i) == 0) { return false; } } return true; } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }