Manipulating numbers is at the core of a programmer's job. To test how well you know their properties, you are asked to solve the following problem.
You are given non-negative integers , , ..., . You want to know whether it's possible to construct a new integer using all the digits of these numbers such that it would be divisible by . You can reorder the digits as you want. The resulting number can contain leading zeros.
For example, consider the numbers from which you have to construct a new integer as described above. Numerous arrangements of digits are possible; but we have illustrated one below.
Complete the function canConstruct which takes an integer array as input and return "Yes" or "No" based on whether or not the required integer can be formed.
The first line contains a single integer denoting the number of queries. The following lines describe the queries.
Each query is described in two lines. The first of these lines contains a single integer . The second contains space-separated integers , , ..., .
For 33.33% of the total score:
For each query, print a single line containing "Yes" if it's possible to construct such integer and "No" otherwise.
Sample Input 0
319340 50 9021 4
Sample Output 0
In the first example, is divisible by , so the answer is "Yes".
In the second example you can construct the number which is divisible by , so the answer is "Yes". Note that there may be other numbers you can construct, some of which are shown in the challenge statement.
In the third example, the only possible numbers are and , but both of them are not divisible by , so the answer is "No".