#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 2;
void testCase() {
  int n, k, cnt = 0, ans = 1, s = 0;
  scanf("%d%d", &n, &k);
  vector<int> a(n), fr(101), z(101);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    if (fr[a[i]]++ == 0) ++cnt, ++s;
    if (cnt == k + 1) cnt = 2, ans++;
  }
  if (s >= 2 && k == 1) {
    puts("-1");
    return;
  }
  cout << ans << endl;
}
int main() {
  int T = 1;
  scanf("%d", &T);
  while (T--) {
    testCase();
  }
}
