#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long ca;
  cin >> ca;
  while (ca--) {
    long long n, i, j, k;
    cin >> n >> k;
    long long a[n + 4], cnt = 1;
    for (i = 0; i < n; i++) {
      cin >> a[i];
      if (i > 0 && a[i] != a[i - 1]) cnt++;
    }
    if (k == 1 && cnt > 1) {
      cout << -1 << endl;
      continue;
    }
    long long ans = 1;
    cnt = cnt - k;
    while (cnt > 0) {
      cnt -= (k - 1);
      ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
