#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 2e18;
const long long MAX1 = 203;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long tc;
  cin >> tc;
  while (tc--) {
    long long n, k;
    cin >> n >> k;
    long long a[n];
    unordered_map<int, int> cnt;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      cnt[a[i]]++;
    }
    if (k == 1) {
      if (cnt.size() == 1)
        cout << 1 << "\n";
      else
        cout << -1 << "\n";
      continue;
    }
    if (k >= cnt.size()) {
      cout << 1 << "\n";
      continue;
    }
    long long x = cnt.size() - k;
    long long ans = (x + k - 2) / (k - 1);
    cout << ans + 1 << "\n";
  }
  return 0;
}
