#include <bits/stdc++.h>
long double pi = acos(-1);
long long z = 1000000007;
long long power(long long a, long long b) {
  if (b == 0) return 1;
  long long c = power(a, b / 2);
  if (b % 2 == 0)
    return c * c;
  else
    return c * c * a;
}
using namespace std;
const int N = 1e6 + 7;
void solve() {
  long long n;
  cin >> n;
  long long k;
  cin >> k;
  map<long long, long long> m;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    m[x]++;
  }
  if (m.size() <= k)
    cout << 1 << endl;
  else if (k == 1 && m.size() > 1)
    cout << -1 << endl;
  else {
    long long ans = (m.size() - k) / (k - 1) + 1;
    if ((m.size() - k) % (k - 1) != 0) ans++;
    cout << ans << endl;
  }
}
int main() {
  long long t;
  cin >> t;
  while (t--) solve();
}
