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