#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + c - '0', c = getchar();
  return x * f;
}
int a[N];
int main() {
  int T = read();
  while (T--) {
    int n = read(), k = read();
    for (int i = 1; i <= n; i++) a[i] = read();
    n = unique(a + 1, a + 1 + n) - a - 1;
    if (k == 1) {
      if (n != 1)
        cout << -1 << endl;
      else
        cout << 1 << endl;
    } else if (k >= n)
      cout << 1 << endl;
    else {
      cout << (n - k) / (k - 1) + ((n - k) % (k - 1) != 0) + 1 << endl;
    }
  }
}
