#include <bits/stdc++.h>
using namespace std;
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    int n, a;
    cin >> n >> a;
    vector<int> vc(n + 5);
    for (int i = 1; i <= n; i++) {
      cin >> vc[i];
    }
    int sum = 0;
    for (int i = 2; i <= n; i++) {
      if (vc[i] != vc[i - 1]) sum++;
    }
    if (sum == 0)
      cout << 1 << endl;
    else if (a == 1 && sum)
      cout << -1 << endl;
    else {
      if (sum % (a - 1) != 0)
        cout << (sum / (a - 1)) + 1 << endl;
      else
        cout << sum / (a - 1) << endl;
    }
  }
  return 0;
}
