#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  constexpr int INF = 1e9;
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      --a[i];
    }
    vector<int> shift(n);
    for (int i = 0; i < n; ++i) shift[i] = i - a[i];
    vector<pair<int, int>> sorted;
    for (int i = 0; i < n; ++i) {
      if (shift[i] >= 0) sorted.push_back({shift[i], a[i]});
    }
    sort(sorted.begin(), sorted.end());
    int ans = INF, len = (int)sorted.size();
    vector<int> dp(k + 1);
    for (int i = 0, cur = 0; i < len && cur != k; ++i) {
      int j =
          lower_bound(dp.begin() + 1, dp.begin() + cur + 1, sorted[i].second) -
          dp.begin();
      dp[j] = sorted[i].second;
      cur = max(cur, j);
      if (j == k) ans = min(ans, sorted[i].first);
    }
    cout << (ans == INF ? -1 : ans) << '\n';
  }
}
