#include <bits/stdc++.h>
using namespace std;
void runcase() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int changes = 0;
  k--;
  for (int i = 1; i < n; i++)
    if (a[i] != a[i - 1]) changes++;
  int ans = 0;
  if (k == 0) {
    if (changes == 0)
      ans = 1;
    else
      ans = -1;
  } else {
    ans = max(1, (changes + k - 1) / k);
  }
  cout << ans << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) runcase();
  return 0;
}
