#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const long double pi = acos(-1);
const long long maxn = 1e6 + 5;
const int mod = 1e9 + 7;
const long long INF = 1e18;
const int MX = 2000000001;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  long long t, q, n, a, b, c, d, k, l, m, r, x = 0, y = 0, z = 0, sum = 0,
                                             ans = 0, temp = 0, res = 0;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    vector<long long> v(n);
    long long diff = 1;
    for (long long i = 0; i < (n); i++) {
      cin >> v[i];
      if (i and v[i] != v[i - 1]) diff++;
    }
    if (k >= diff) {
      cout << "1\n";
      continue;
    }
    if (k == 1 and diff > 1) {
      cout << "-1\n";
      continue;
    }
    ans = 1 + (diff - 2) / (k - 1);
    cout << ans << "\n";
  }
}
