/** ____ ____ ____ ____ ____ ____ ||l |||e |||i |||n |||a |||d || ||__|||__|||__|||__|||__|||__|| |/__\|/__\|/__\|/__\|/__\|/__\| **/ #include #define endl '\n' using namespace std; typedef long long ll; const int maxn = 10010; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int n, k, a[maxn]; bool sorted() { for (int i = 1; i <= n; i ++) if (a[i] != i) return false; return true; } void do_step() { for (int i = 1; i <= n - k + 1; i ++) { sort(a + i, a + i + k); } } void solve() { cin >> n >> k; for (int i = 1; i <= n; i ++) cin >> a[i]; int cnt = 0; while(!sorted()) { cnt ++; do_step(); } cout << cnt << endl; } int main() { freopen ("partsort.in", "r", stdin); freopen ("partsort.out", "w", stdout); int t; cin >> t; while(t --) solve(); return 0; } /** 3 5 3 4 5 3 1 2 3 2 1 2 3 7 7 7 6 5 4 3 2 1 */