#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n, k, ans = 0;
    cin >> n >> k;
    vector<int> a(n);
    for (auto &x : a) cin >> x;
    int cnt = 1;
    for (int i = 0; i + 1 < n; i++) {
      cnt += a[i] != a[i + 1];
    }
    if (k == 1) {
      cout << (cnt > 1 ? -1 : 1) << "\n";
      continue;
    }
    --k;
    ans += (cnt - 1 + k - 1) / k;
    if (!ans) ++ans;
    cout << ans << "\n";
  }
}
