#include <bits/stdc++.h>
using namespace std;
const int N = 110;
long long t, n, k, a[N];
int solve() {
  scanf("%lld", &t);
  while (t--) {
    scanf("%lld%lld", &n, &k);
    long long cnt = 1;
    for (int i = 0; i < n; i++) {
      scanf("%lld", &a[i]);
      if (i && a[i] != a[i - 1]) cnt++;
    }
    if (k == 1) {
      if (cnt > 1)
        printf("-1\n");
      else {
        printf("1\n");
      }
      continue;
    }
    long long res = 0;
    if (cnt == 1 && a[0]) res++;
    while (cnt > 1) {
      res++;
      cnt -= k;
      cnt++;
    }
    printf("%lld\n", res);
  }
  return 0;
}
int main() { return solve(); }
