All Submissions


Background
Given n numbers, determine whether n-1 numbers can be converted to 0 using following operation any number of times :
A subset of non-zero numbers (possibly empty) are chosen. Numbers in the chosen subset are decremented by 1, and the numbers not in the subset are incremented by K.

Input Specifications
The first line contains the number of test cases T. 2*T lines follow, 2 for each case.
The first line of a test case contains the numbers n and K.
The next line contains n numbers, a_1...a_n.

Output Specifications
Output T lines, one corresponding to each test case.
For a test case, output "YES" if there is a sequence of operations as described, and "NO" otherwise.

Sample Input

3
2 1
10 10
3 2
1 2 2
3 2
1 2 3


Sample Output

YES
YES
NO


Constraints
Number of Test Cases T,
1 < T <= 1000
2 < n <= 100
1 < k <= 10
0 < a_i <= 1200
Problem Setter : Vivek Bhatnagar

Languages: C,C++,C#,Java,JavaScript,Pascal,Perl,PHP,Python,Ruby,Text

Time Limit: 1 Second(s)
Score: 100 Point(s)
Input File Limit: 50000 Bytes

Submit

Login to post clarification.

No Clarifications.

Contest

Mode Judge

Passive

Online

Overall Rankings

RankNameScore
1xyz0
2Ams0
3TIP0
4team420
5xyzz0
6asdasdasd0
7abcd0
8khankhan0
9Gabriel0
10gigel0