#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    vector<int> tmp(n + 1, 0);
    vector<vector<int>> dp(n + 1, tmp);
    for (int i = 0; i < n; i++) {
      cin >> v[i];
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j <= i; j++) {
        if (dp[i + 1][j] < dp[i][j]) {
          dp[i + 1][j] = dp[i][j];
        }
        if (v[i] == j + 1) {
          dp[i + 1][j + 1] = dp[i][j] + 1;
        } else if (dp[i + 1][j + 1] < dp[i][j]) {
          dp[i + 1][j + 1] = dp[i][j];
        }
      }
    }
    bool b = 0;
    for (int i = n; i >= 0; i--) {
      if (dp[n][i] >= k) {
        cout << n - i << "\n";
        b = 1;
        break;
      }
    }
    if (!b) {
      cout << "-1\n";
    }
  }
}
