#include <bits/stdc++.h>
using namespace std;
const int MX = 1000005;
int main() {
  cin.tie(0)->sync_with_stdio(0);
  int tc;
  cin >> tc;
  for (int n, k; tc--;) {
    cin >> n >> k;
    set<int> sz;
    for (int x, i = 0; i < n; i++) {
      cin >> x;
      sz.insert(x);
    }
    int cc = (int)sz.size(), ans;
    if (cc <= k)
      ans = 1;
    else if (k == 1)
      ans = -1;
    else
      ans = (cc - k - 1) / (k - 1) + 2;
    cout << ans << endl;
  }
  return 0;
}
