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