#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  long long t;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    vector<long long> a(n);
    set<long long> s;
    for (long long i = 0; i < n; ++i) cin >> a[i], s.insert(a[i]);
    long long num = (long long)s.size();
    if (k == 1 && num > 1) {
      cout << -1 << '\n';
      continue;
    }
    long long ans = 1;
    if (num > k) {
      num -= k;
      ans += (num + k - 2) / (k - 1);
    }
    cout << ans << '\n';
  }
  return 0;
}
