#include <bits/stdc++.h>
using namespace std;
bool comp1(int& a, int& b);
int64_t gcd(int64_t a, int64_t b);
bool comp2(int& a, int& b);
bool comp3(pair<int, int>& a, pair<int, int>& b);
bool comp4(pair<int, int>& a, pair<int, int>& b);
bool isPrime(int& x);
void input(vector<int>& v, int& n) {
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
}
int sum(vector<int>& v) {
  int s = 0;
  for (auto& el : v) {
    s += el;
  }
  return s;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    set<int> cnt;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      cnt.insert(a[i]);
    }
    int cntNums = (int)cnt.size();
    int ans = 0;
    if (k == 1) {
      if (cntNums == 1) {
        ans = 1;
      } else {
        ans = -1;
      }
    } else if (k >= cntNums) {
      ans = 1;
    } else {
      ans = (cntNums - k) / (k - 1) + 1 + (((cntNums - k) % (k - 1)) > 0);
    }
    cout << ans << endl;
  }
  return 0;
}
