#include <bits/stdc++.h>
using namespace std;
void Expert_ban_ne_ka_hai_mereko() {
  long long int n, k;
  cin >> n >> k;
  vector<long long int> arr(n);
  set<long long int> st;
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
    st.insert(arr[i]);
  }
  long long int c = st.size();
  if (k == 1 and c != 1) {
    cout << -1;
    ;
    return;
  }
  long long int ans = 0;
  c -= k;
  ans++;
  while (c > 0) {
    c -= (k - 1);
    ans++;
  }
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1;
  cin >> t;
  for (long long int test = 1; test <= t; test++) {
    Expert_ban_ne_ka_hai_mereko();
    cout << endl;
  }
  return 0;
}
