#P1374D. Zero Remainder Array
Zero Remainder Array
No submission language available for this problem.
Description
You are given an array consisting of positive integers.
Initially, you have an integer . During one move, you can do one of the following two operations:
- Choose exactly one from to and increase by (), then increase by ().
- Just increase by ().
The first operation can be applied no more than once to each from to .
Your task is to find the minimum number of moves required to obtain such an array that each its element is divisible by (the value is given).
You have to answer independent test cases.
The first line of the input contains one integer () — the number of test cases. Then test cases follow.
The first line of the test case contains two integers and () — the length of and the required divisior. The second line of the test case contains integers (), where is the -th element of .
It is guaranteed that the sum of does not exceed ().
For each test case, print the answer — the minimum number of moves required to obtain such an array that each its element is divisible by .
Input
The first line of the input contains one integer () — the number of test cases. Then test cases follow.
The first line of the test case contains two integers and () — the length of and the required divisior. The second line of the test case contains integers (), where is the -th element of .
It is guaranteed that the sum of does not exceed ().
Output
For each test case, print the answer — the minimum number of moves required to obtain such an array that each its element is divisible by .
Samples
Note
Consider the first test case of the example:
- , . Just increase ;
- , . Add to the second element and increase ;
- , . Add to the third element and increase ;
- , . Add to the fourth element and increase ;
- , . Just increase ;
- , . Add to the first element and increase ;
- , . We obtained the required array.
Note that you can't add to the same element more than once.