#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    unordered_map<long long, long long> unique;
    for (long long i = 0; i < n; i += 1) {
      long long te;
      cin >> te;
      if (unique.count(te) == 0) unique[te] = 1;
    }
    if (unique.size() <= k)
      cout << 1 << "\n";
    else if (k != 1) {
      if ((unique.size() - k) % (k - 1) != 0)
        cout << 1 + (unique.size() - k) / (k - 1) + 1 << "\n";
      else
        cout << 1 + (unique.size() - k) / (k - 1) << "\n";
    } else
      cout << -1 << "\n";
  }
}
