using System;
using System.Text;
using CompLib.Mathematics;
public class Program
{
public void Solve()
{
var sc = new Scanner();
int q = sc.NextInt();
var sb = new StringBuilder();
for (int i = 0; i < q; i++)
{
sb.AppendLine(Query(sc.NextLong()));
}
Console.Write(sb.ToString());
}
string Query(long n)
{
// Goldbach's conjecture
// n <= 10^18では真
if (n % 2 == 0)
{
return n == 2 ? "No" : "Yes";
}
// nは奇数
// p,qが奇素数ならnは偶数になるはず
// どちらかは2
// 対称性より p = 2とする
if (n < 5) return "No";
for (long pa = 2; pa < n; pa *= 2)
{
long qb = n - pa;
if (PrimalityTest.IsPrime(qb))
{
return "Yes";
}
for (long b = 2; b <= 60; b++)
{
long min = 0;
long max = (long) Math.Pow(long.MaxValue, (double) 1 / b);
while (max - min > 1)
{
long med = (max + min) / 2;
if (Pow(med, b) <= qb)
{
min = med;
}
else
{
max = med;
}
}
if (min < 2) break;
if (Pow(min, b) == qb && PrimalityTest.IsPrime(min))
{
return "Yes";
}
}
}
return "No";
}
public long Pow(long a, long b)
{
if (b == 0) return 1;
long res = Pow(a * a, b / 2);
if (b % 2 == 1) res *= a;
return res;
}
public static void Main(string[] args)
{
new Program().Solve();
}
}
namespace CompLib.Mathematics
{
using System;
public static class PrimalityTest
{
private static Random Random = new Random();
///
/// Miller-Rabin素数判定法を用いてnが素数か判定 O(k log^2 n)
///
///
///
///
public static bool IsPrime(long n, int k = 60)
{
if (n < 2) return false;
if (n == 2) return true;
if (n % 2 == 0) return false;
if (n < 10000)
{
for (int i = 3; i * i <= n; i++)
{
if (n % i == 0)
{
return false;
}
}
return true;
}
if (!StrongFermatTest(2, n))
{
return false;
}
for (int i = 0; i < k; i++)
{
if (!StrongFermatTest(NextLong(2, n), n))
{
return false;
}
}
return true;
}
public static bool StrongFermatTest(long a, long n)
{
long t = n - 1;
long t2 = t;
while (t % 2 == 0)
{
t /= 2;
if (Pow(a, t, n) == t2)
{
return true;
}
}
return Pow(a, t, n) == 1;
}
private static long Pow(long x, long y, long mod)
{
x %= mod;
long result = 1;
while (y > 0)
{
if (y % 2 == 1)
{
result = Multiplication(result, x, mod);
}
x = Multiplication(x, x, mod);
y /= 2;
}
return result;
}
private static long Multiplication(long a, long b, long mod)
{
if (mod < int.MaxValue)
{
return (a * b) % mod;
}
long result = 0;
while (b > 0)
{
if (b % 2 == 1)
{
result += a;
result %= mod;
}
a *= 2;
a %= mod;
b /= 2;
}
return result;
}
private static long NextLong(long min, long max)
{
long d = max - min;
long result = Random.Next();
result <<= 31;
result += Random.Next();
result %= d;
return result + min;
}
}
}
class Scanner
{
public Scanner()
{
_pos = 0;
_line = new string[0];
}
const char Separator = ' ';
private int _pos;
private string[] _line;
#region スペース区切りで取得
public string Next()
{
if (_pos >= _line.Length)
{
_line = Console.ReadLine().Split(Separator);
_pos = 0;
}
return _line[_pos++];
}
public int NextInt()
{
return int.Parse(Next());
}
public long NextLong()
{
return long.Parse(Next());
}
public double NextDouble()
{
return double.Parse(Next());
}
#endregion
#region 型変換
private int[] ToIntArray(string[] array)
{
var result = new int[array.Length];
for (int i = 0; i < array.Length; i++)
{
result[i] = int.Parse(array[i]);
}
return result;
}
private long[] ToLongArray(string[] array)
{
var result = new long[array.Length];
for (int i = 0; i < array.Length; i++)
{
result[i] = long.Parse(array[i]);
}
return result;
}
private double[] ToDoubleArray(string[] array)
{
var result = new double[array.Length];
for (int i = 0; i < array.Length; i++)
{
result[i] = double.Parse(array[i]);
}
return result;
}
#endregion
#region 配列取得
public string[] Array()
{
if (_pos >= _line.Length)
_line = Console.ReadLine().Split(Separator);
_pos = _line.Length;
return _line;
}
public int[] IntArray()
{
return ToIntArray(Array());
}
public long[] LongArray()
{
return ToLongArray(Array());
}
public double[] DoubleArray()
{
return ToDoubleArray(Array());
}
#endregion
}