#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    long long a[n], m, sz, flag = 1, first = 1;
    for (auto &x : a) cin >> x;
    ;
    set<long long> s;
    for (auto x : a) s.insert(x);
    sz = (long long)s.size();
    if (sz <= k)
      m = 1;
    else {
      m = 0;
      s.clear();
      for (long long i = 0; i < n; ++i) {
        s.insert(a[i]);
        if (k > 0 && (long long)s.size() > k) {
          m++;
          if (first == 1) k--, first = 0;
          flag = 1;
          s.clear();
          s.insert(a[i]);
        } else if (k == 0) {
          flag = 0;
          break;
        }
      }
      if (flag == 1 && (long long)s.size() && k > 0)
        m++, s.clear();
      else if (flag == 1 && k == 0)
        m = -1;
      else
        m = -1;
    }
    cout << m << "\n";
  }
  return 0;
}
