#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int dp[2005][2005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  cin >> T;
  while (T--) {
    int n, k;
    cin >> n >> k;
    vector<int> a(n + 1);
    for (int i = 0; i < n; ++i) cin >> a[i + 1];
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < n; ++i)
      for (int j = 0; j <= i; ++j) {
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        dp[i + 1][j + 1] =
            max(dp[i + 1][j + 1], dp[i][j] + (a[i + 1] == j + 1));
      }
    int ans = -1;
    for (int i = n; i >= 0; --i)
      if (dp[n][i] >= k) {
        ans = n - i;
        break;
      }
    cout << ans << '\n';
  }
}
