#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
void solve() {
  ll n, k;
  cin >> n >> k;
  vector<ll> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  ll dp[n][n];
  for (int i = 1; i < n; i++) dp[0][i] = 0;
  ll curr = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] == (i + 1)) curr += 1;
    dp[i][0] = curr;
  }
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < n; j++) {
      ll temp = (arr[i] == (i - j + 1));
      dp[i][j] = max(dp[i - 1][j - 1], dp[i - 1][j] + temp);
    }
  }
  ll ans = -1;
  for (int i = 0; i < n; i++) {
    if (dp[n - 1][i] >= k) {
      ans = i;
      break;
    }
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
