#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    int a[n];
    vector<int> skirtingi;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (skirtingi.size() == 0)
        skirtingi.push_back(a[i]);
      else if (skirtingi[skirtingi.size() - 1] != a[i])
        skirtingi.push_back(a[i]);
    }
    if (k == 1) {
      bool negalima = false;
      if (skirtingi.size() > 1) negalima = true;
      if (negalima) {
        cout << "-1\n";
        continue;
      }
    }
    int m = 1;
    while (m * (k - 1) + 1 < skirtingi.size()) m++;
    cout << m << "\n";
  }
  return 0;
}
