#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n, m, k, t;
  vector<int64_t> arr;
  vector<vector<int64_t>> buf;
  int64_t tests;
  cin >> tests;
  for (int test = 0; test < tests; test++) {
    cin >> n >> k;
    arr = vector<int64_t>(n);
    buf = vector<vector<int64_t>>(n + 1, vector<int64_t>(n + 1, 0));
    for (int i = 0; i < n; i++) cin >> arr[i];
    for (int i = 1; i < n + 1; i++) {
      for (int j = 1; j <= i; j++) {
        buf[i][j] = max(buf[i][j], buf[i - 1][j]);
        buf[i][j] = max(buf[i][j], buf[i - 1][j - 1] + (arr[i - 1] == j));
      }
    }
    t = -1;
    for (int i = n; i > 0; i--) {
      if (buf[n][i] >= k) {
        t = n - i;
        break;
      }
    }
    cout << t << endl;
  }
}
