#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, diffNums;
  cin >> n >> diffNums;
  set<int> sum;
  while (n--) {
    int temp;
    cin >> temp;
    sum.insert(temp);
  }
  if (diffNums == 1 && sum.size() > 1) {
    cout << "-1\n";
    return;
  }
  if (static_cast<int>(sum.size()) <= diffNums) {
    cout << "1\n";
    return;
  }
  long counter =
      ceil((static_cast<float>(sum.size()) - diffNums) / (diffNums - 1)) + 1;
  cout << counter << '\n';
}
int main() {
  int n;
  cin >> n;
  while (n--) solve();
}
