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