#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k, i;
    cin >> n >> k;
    int a[n];
    set<int> s;
    for (i = 0; i < n; i++) {
      cin >> a[i];
      s.insert(a[i]);
    }
    int sz = s.size();
    if (sz >= 2 && k == 1)
      cout << "-1\n";
    else if (sz <= k)
      cout << "1\n";
    else {
      if ((sz - k) % (k - 1) != 0)
        cout << (sz - k) / (k - 1) + 2;
      else
        cout << (sz - k) / (k - 1) + 1;
      cout << "\n";
    }
  }
  return 0;
}
