#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 20;
const long long inf = 1e10;
int a[N];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    bool e = true;
    int ans = 1, d = 1, pos = 1;
    while (pos != n && e) {
      if (a[pos] != a[pos - 1]) {
        if (d > k) {
          e = false;
        } else if (d == k) {
          d = 2, ans++;
        } else {
          d++;
        }
      }
      pos++;
    }
    if (d > k) e = false;
    if (!e)
      cout << -1 << endl;
    else
      cout << ans << endl;
  }
}
