Limits 2s, 512 MB

You have an array containing N elements. In one move you can either increase or decrease the value of an element by K.

Your task is to make all the values of the array equal. If it is possible, print the minimum number of moves required to do this. Otherwise print "Impossible".

Input

The first will contain an integer T denoting the number of test cases.

For every case, the first line contains two integers N and K.

The next line contains N integers denoting the elements of the array.

Constraints:

1 ≤ T ≤ 100

1 ≤ N ≤ 1000

0 ≤ K ≤ 1000000

0 ≤ Array Elements Value ≤ 10000000

Output

For each test case, if it is possible to make all the values equal, print the minimum number of moves required. Otherwise print "Impossible".

Sample

InputOutput
3
3 1
2 1 1
4 2
9 1 7 3
4 2
2 4 6 7
1
6
Impossible

Submit

Login to submit.

Statistics

68% Solution Ratio
MathProgrammerEarliest, Aug '19
steinumFastest, 0.0s
MathProgrammerLightest, 131 kB
steinumShortest, 660B
Toph uses cookies. By continuing you agree to our Cookie Policy.