#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;
int T, n, k, A[N], f[N], res;
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &n, &k);
    res = N;
    for (int i = (1); i <= (n); i++) scanf("%d", A + i), A[i] = i - A[i];
    for (int i = (1); i <= (n); i++) {
      f[i] = (A[i] == 0) ? 1 : 0;
      if (A[i] < 0) continue;
      for (int j = (0); j <= (i - 1); j++) {
        if (A[i] == A[j])
          f[i] = max(f[j] + 1, f[i]);
        else if (A[i] > A[j] && A[i] - A[j] <= i - j - 1)
          f[i] = max(f[j] + 1, f[i]);
      }
      if (f[i] >= k) res = min(res, A[i]);
    }
    if (res == N) res = -1;
    printf("%d\n", res);
  }
  return 0;
}
