import java.math.BigInteger fun main() { val n_num = readLine()!!.toInt() repeat(n_num) { val bg = readLine()!!.toBigInteger() val isp = IsPrime.Miller_Rabin.isPrime(bg) println(if (isp) "Yes" else "No") } } class IsPrime { companion object Miller_Rabin { fun isPrime(num: BigInteger) : Boolean{ if (1.toBigInteger() == num) return false if (2.toBigInteger() == num) return true if (num.mod(2.toBigInteger()) == BigInteger.ZERO) return false var s = 0 var t = num - 1.toBigInteger() while (t.and(1.toBigInteger()) == BigInteger.ZERO) { s = s + 1 t = t.shr(1) } val a = 3.toBigInteger() if (a.modPow(t, num) == 1.toBigInteger()) return true for (i in 0..s-1) if (a.modPow(2.toBigInteger().pow(i), num) == num.minus(1.toBigInteger())) return true return false } } }