#P1966A. Card Exchange

    ID: 10624 Type: RemoteJudge 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 3 Uploaded By: Tags>constructive algorithmsgamesgreedy*800

Card Exchange

Description

You have a hand of nn cards, where each card has a number written on it, and a fixed integer kk. You can perform the following operation any number of times:

  • Choose any kk cards from your hand that all have the same number.
  • Exchange these cards for k1k-1 cards, each of which can have any number you choose (including the number written on the cards you just exchanged).

Here is one possible sequence of operations for the first example case, which has k=3k=3:

What is the minimum number of cards you can have in your hand at the end of this process?

The first line of the input contains a single integer tt (1t5001 \le t \le 500) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers nn and kk (1n1001 \le n \le 100, 2k1002 \le k \le 100) — the number of cards you have, and the number of cards you exchange during each operation, respectively.

The next line of each test case contains nn integers c1,c2,cnc_1, c_2, \ldots c_n (1ci1001 \le c_i \le 100) — the numbers written on your cards.

For each test case, output a single integer — the minimum number of cards you can have left in your hand after any number of operations.

Input

The first line of the input contains a single integer tt (1t5001 \le t \le 500) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers nn and kk (1n1001 \le n \le 100, 2k1002 \le k \le 100) — the number of cards you have, and the number of cards you exchange during each operation, respectively.

The next line of each test case contains nn integers c1,c2,cnc_1, c_2, \ldots c_n (1ci1001 \le c_i \le 100) — the numbers written on your cards.

Output

For each test case, output a single integer — the minimum number of cards you can have left in your hand after any number of operations.

Sample Input 1

7
5 3
4 1 1 4 4
1 10
7
7 2
4 2 1 100 5 2 3
10 4
1 1 1 1 1 1 1 1 1 1
5 2
3 8 1 48 7
6 2
10 20 30 10 20 40
6 3
10 20 30 10 20 40

Sample Output 1

2
1
1
3
5
1
6

Note

The first example case corresponds to the picture above. The sequence of operations displayed there is optimal, so the answer is 22.

In the second example case, no operations can be performed, so the answer is 11.

In the fourth example case, you can repeatedly select 44 cards numbered with 11 and replace them with 33 cards numbered with 11, until there are 33 cards left.