#include <bits/stdc++.h>
using namespace std;
template <class T>
void show(const vector<T> &a) {
  for (T x : a) cout << x << " ";
  cout << '\n';
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());
vector<long long> xx = {1, 0, -1, 0, 1, -1, 1, -1};
vector<long long> yy = {0, 1, 0, -1, -1, -1, 1, 1};
string dir = "RDLU";
string travel = "ENWS";
const long long N = 1e5 + 50, oo = 1e18 + 500;
const long long mod = 998244353;
const long long M2 = 1000000093, x2 = 27162;
const long long M1 = 1000000087, x1 = 241;
const long double eps = 1e-18, PI = 2 * acos(0.0);
long long cnt = 0;
vector<vector<long long> > g;
vector<vector<long long> > rg;
signed main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n);
    set<long long> st;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      st.insert(a[i]);
    }
    if (((long long)(st.size())) > 1 && k <= 1) {
      cout << -1 << '\n';
      continue;
    }
    st.clear();
    cnt = 0;
    long long fl = 0;
    for (long long i = 0; i < n; i++) {
      st.insert(a[i]);
      if (((long long)(st.size())) > k - fl) {
        fl = 1;
        st = {a[i]};
        cnt++;
      }
    }
    if (((long long)(st.size()))) cnt++;
    cout << cnt << '\n';
  }
}
