#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9 + 7;
int n, k;
int a[123];
void solve() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int j = 1; j <= n; j++) {
    int q = 0;
    int x = 0;
    for (int i = 0; i < n && q <= k; i++) {
      if (i == 0 || a[i - 1] != a[i]) {
        q++;
      }
      if (q <= k) {
        x = i;
      }
    }
    for (int i = x + 1; i < n; i++) {
      a[i] -= a[x];
    }
    for (int i = 0; i <= x; i++) {
      a[i] = 0;
    }
    if (a[n - 1] == 0) {
      printf("%d\n", j);
      return;
    }
  }
  puts("-1");
}
int main() {
  int test;
  scanf("%d", &test);
  while (test--) {
    solve();
  }
}
