CF1415B.Repainting Street

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Repainting Street

There is a street with nn houses in a line, numbered from 11 to nn. The house ii is initially painted in color cic_i. The street is considered beautiful if all houses are painted in the same color. Tom, the painter, is in charge of making the street beautiful. Tom's painting capacity is defined by an integer, let's call it kk.

On one day, Tom can do the following repainting process that consists of two steps:

  1. He chooses two integers ll and rr such that 1lrn1 \le l \le r \le n and rl+1=kr - l + 1 = k.
  2. For each house ii such that lirl \le i \le r, he can either repaint it with any color he wants, or ignore it and let it keep its current color.

Note that in the same day Tom can use different colors to repaint different houses.

Tom wants to know the minimum number of days needed to repaint the street so that it becomes beautiful.

Input

The first line of input contains a single integer tt (1t1041 \le t \le 10^4), the number of test cases. Description of test cases follows.

In the first line of a test case description there are two integers nn and kk (1kn1051 \le k \le n \le 10^5).

The second line contains nn space-separated integers. The ii-th of these integers represents cic_i (1ci1001 \le c_i \le 100), the color which house ii is initially painted in.

It is guaranteed that the sum of nn over all test cases does not exceed 10510^5.

Output

Print tt lines, each with one integer: the minimum number of days Tom needs to make the street beautiful for each test case.

Note

In the first test case Tom should paint houses 1 and 2 in the first day in color 2, houses 5 and 6 in the second day in color 2, and the last house in color 2 on the third day.

In the second test case Tom can, for example, spend 6 days to paint houses 1, 2, 4, 5, 6, 7 in color 3.

In the third test case Tom can paint the first house in the first day and houses 6, 7, and 8 in the second day in color 3.

Samples

3
10 2
1 1 2 2 1 1 2 2 2 1
7 1
1 2 3 4 5 6 7
10 3
1 3 3 3 3 1 2 1 3 3
3
6
2

在线编程 IDE

建议全屏模式获得最佳体验