#C3159. Prime Permutation
Prime Permutation
Prime Permutation
Given an integer, determine if there exists any permutation of its digits that forms a prime number. A prime number is defined as a number greater than \(1\) that has no positive divisors other than \(1\) and itself.
For instance, consider the number 13. One of its permutations is 31, which is a prime number. If any permutation of the digits of the given number is prime, then the answer is "YES"; otherwise, the answer is "NO".
You need to process multiple test cases.
inputFormat
The first line contains a single integer \(T\) representing the number of test cases. Each of the following \(T\) lines contains a single integer \(N\).
Example:
3
13
31
245
outputFormat
For each test case, output a single line with either "YES" if there exists a permutation of digits of \(N\) that is a prime number, or "NO" otherwise.
Example Output:
YES
YES
NO
3
13
31
245
YES
YES
NO
</p>