#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k;
  cin >> n >> k;
  long long a[n + 1];
  for (long long i = 1; i <= n; i++) cin >> a[i];
  long long cnt = 1;
  for (long long i = 2; i <= n; i++) {
    if (a[i] != a[i - 1]) cnt++;
  }
  if (k == 1) {
    if (cnt == 1)
      cout << 1 << endl;
    else
      cout << -1 << endl;
    return;
  }
  if (cnt == 1) {
    cout << 1 << endl;
    return;
  }
  cnt--;
  k--;
  long long ans = ((cnt + k - 1) / k);
  cout << ans << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) solve();
  return 0;
}
