#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int N, K;
    scanf("%d %d", &N, &K);
    int element = 0;
    int prev = -1;
    int temp;
    int cur, bit;
    for (int f = 0; f < N; f++) {
      scanf("%d", &temp);
      if (temp != prev) element++;
      prev = temp;
    }
    if (K == 1 && element > 1)
      printf("-1\n");
    else if (K == 1)
      printf("1\n");
    else {
      element -= K;
      if (element < 0) element = 0;
      int ans = element / (K - 1) + 1;
      if (element > 0 && element % (K - 1) != 0) ans++;
      printf("%d\n", ans);
    }
  }
}
