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