#include <bits/stdc++.h>
using namespace std;
int T, n, k, a[2010], f[2010];
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++)
      if (a[i] > i)
        f[i] = 0;
      else {
        f[i] = 1;
        for (int j = 1; j < i; j++)
          if (a[j] < a[i] && i - j >= a[i] - a[j]) f[i] = max(f[i], f[j] + 1);
      }
    int ans = n;
    for (int i = 1; i <= n; i++)
      if (f[i] >= k) ans = min(ans, i - a[i]);
    if (ans == n)
      puts("-1");
    else
      printf("%d\n", ans);
  }
  return 0;
}
