#C2547. Prime Permutations

    ID: 45875 Type: Default 1000ms 256MiB

Prime Permutations

Prime Permutations

Given a string S consisting of digits, determine whether it is possible to rearrange its digits to form a prime number.

A prime number is defined as a positive integer greater than 1 that has no divisors other than 1 and itself.

Input: The first line contains an integer T, the number of test cases. Each of the next T lines contains a non-empty string S composed of digits.

Output: For each test case, print a single line with YES if some permutation of S is a prime number, or NO otherwise.

inputFormat

The input is read from standard input. The first line contains an integer T, representing the number of test cases. Each of the following T lines contains a string S comprised of digits.

outputFormat

For each test case, output a single line to standard output: YES if it's possible to rearrange the digits of S to form a prime number, and NO otherwise.## sample

3
17
23
28
YES

YES NO

</p>