PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000048. Kiểm tra nhiều số nguyên tố (FPRIME)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Kiểm tra nhiều số nguyên tố (FPRIME)

FPRIME

Source: LQDOJ

Version: Phuoc Hung OJ Extended

Problem Statement

You are given KK natural numbers N1,N2,…,NKN_1,N_2,\ldots,N_K. For each NiN_i, determine whether it is prime. Answer each query independently, preserving input order.

Input

The first line contains a positive integer KK. Each of the next KK lines contains one natural number NiN_i.

Output

Print exactly KK lines: YES if NiN_i is prime, and NO otherwise.

Subtasks

  • Subtask 1 (20 points): 1≤K≤9991\le K\le 999; 0≤Ni≤99999990\le N_i\le 9999999 for every 1≤i≤K1\le i\le K.
  • Subtask 2 (80 points): 1≤K≤9999991\le K\le 999999; 0≤Ni≤99999990\le N_i\le 9999999 for every 1≤i≤K1\le i\le K.

Examples

Input

2
2
9

Output

YES
NO

Explanation

There are K=2K=2 queries. The first number N1=2N_1=2 is prime, so print YES. The second number N2=9=3⋅3N_2=9=3\cdot3 has a nontrivial divisor, so print NO.