#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int a[105];
void solve() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int ans = 0;
  while (1) {
    ans++;
    int cnt = 1;
    for (int i = 2; i <= n; i++) {
      cnt += a[i] != a[i - 1];
    }
    if (cnt <= m) {
      cout << ans << '\n';
      return;
    }
    cnt = 0;
    for (int i = 1; i <= n; i++) {
      cnt += a[i] != a[i - 1] || i == 1;
      if (cnt == m) {
        if (!a[i]) {
          cout << -1 << '\n';
          return;
        }
        for (int j = i + 1; j <= n; j++) a[j] -= a[i];
        for (int j = 1; j <= i; j++) a[j] = 0;
        break;
      }
    }
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
