#include <bits/stdc++.h>
using namespace std;
void inout();
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  if (k == 1 && arr[0] != arr[n - 1]) {
    cout << -1 << endl;
    return;
  }
  if (arr[0] == arr[n - 1]) {
    cout << 1 << endl;
    return;
  }
  set<int> s;
  for (int i = 0; i < n; i++) s.insert(arr[i]);
  int len = s.size();
  len = len - k;
  if (len <= 0) {
    cout << 1 << endl;
    return;
  }
  if (len % (k - 1) == 0) {
    int temp = len / (k - 1);
    cout << temp + 1 << endl;
    return;
  }
  int temp = (len / (k - 1));
  cout << temp + 2 << endl;
  return;
}
int main() {
  inout();
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
void inout() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
