#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k, x;
    cin >> n >> k;
    set<int> s;
    for (int i = 0; i < n; i++) {
      cin >> x;
      s.insert(x);
    }
    int dif = s.size();
    dif--;
    int ans = 0;
    if (dif == 0) {
      ans = 1;
    } else {
      if (k == 1)
        ans = -1;
      else
        ans = (dif + k - 2) / (k - 1);
    }
    cout << ans << '\n';
  }
}
