#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T read() {
  T f = 0, x = 0;
  char c = getchar();
  while (!isdigit(c)) f = c == '-', c = getchar();
  while (isdigit(c)) x = x * 10 + c - 48, c = getchar();
  return f ? -x : x;
}
namespace run {
const int N = 109;
int n, a[N], k;
int main() {
  int T = read<int>();
  while (T--) {
    n = read<int>(), k = read<int>();
    for (int i = 1; i <= n; i++) a[i] = read<int>();
    if (k == 1) {
      int peg = 0;
      for (int i = 2; i <= n; i++)
        if (a[i] ^ a[i - 1]) peg = 1;
      if (peg)
        puts("-1");
      else
        puts("1");
      continue;
    }
    int ans = 1;
    for (int i = 1, tmp = a[1] == 0; i <= n; i++) {
      if (a[i] != a[i - 1]) {
        if (tmp == k) ans++, tmp = 1;
        tmp++;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
}  // namespace run
int main() { return run::main(); }
