#include <bits/stdc++.h>
using namespace std;
void swap(long long &a, long long &b) {
  long long t = a;
  a = b;
  b = t;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    set<long long> s;
    long long arr[n];
    for (long long i = 0; i < n; i++) {
      cin >> arr[i];
      s.insert(arr[i]);
    }
    if (n > 1 && s.size() > 1 && k == 1) {
      cout << -1 << endl;
      continue;
    }
    if (s.size() == 1) {
      cout << 1 << endl;
      continue;
    }
    long long count = 0;
    while (1) {
      if (s.size() == 1) {
        break;
      }
      set<long long> s1;
      long long j = 0;
      long long last = 0;
      for (auto x : s) {
        if (j < k) {
          s1.insert(0);
          j++;
          last = x;
        } else {
          s1.insert(x - last);
          j++;
        }
      }
      count++;
      s = s1;
    }
    cout << count << endl;
  }
}
