#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long N = 2e3 + 10;
const long long MOD = 998244353;
const long long inf = 1e10;
const long double eps = 1e-12;
const long double EPS = 1e-10;
long long rx[] = {1, -1, 0, 0};
long long ry[] = {0, 0, 1, -1};
long long dp[N][N];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long Q;
  cin >> Q;
  while (Q--) {
    long long n, k;
    cin >> n >> k;
    for (long long i = 0; i <= n; ++i) {
      for (long long j = 0; j <= n; ++j) dp[i][j] = 0;
    }
    vector<long long> a(n + 1);
    for (long long i = 1; i <= n; ++i) cin >> a[i];
    for (long long i = 0; i < n; ++i) {
      for (long long j = 0; j <= i; ++j) {
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        if (a[i + 1] == j + 1)
          dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
        else
          dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j]);
      }
    }
    long long ans = -1;
    for (long long i = 1; i <= n; ++i) {
      for (long long j = 1; j <= n; ++j) {
        if (dp[i][j] >= k) ans = max(ans, j);
      }
    }
    if (ans != -1) ans = n - ans;
    cout << ans << '\n';
  }
  return 0;
}
