#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5 + 5;
int N, K, a[MAX_N];
int b[MAX_N], cnt;
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%d %d", &N, &K);
    for (int i = 1; i <= N; i++) scanf("%d", a + i);
    int ans = 0;
    while (a[N] && ans <= N) {
      if (!ans) {
        int t = a[1];
        for (int i = 1; i <= N; i++) a[i] -= t;
      }
      for (int i = 1; i < K; i++)
        for (int j = 1; j <= N; j++)
          if (a[j]) {
            int t = a[j];
            for (int k = j; k <= N; k++) a[k] -= t;
            break;
          }
      ++ans;
    }
    if (ans > N)
      puts("-1");
    else
      printf("%d\n", ans);
  }
  return 0;
}
