#include <iostream>
#include <fstream>
//#include "windows.h"
#include <algorithm>
using namespace std;

int gcd(int a, int b) {
	while(a > 0) {
		a^=b^=a^=b%=a;
	}
	return b;
}
long long a[100003], b[100003];
int main() {
	ifstream I("LADDER.IN");
	int t;
	I >> t;
	for (; t--; ){
		int n, k;
		I >> n >> k;
		for (int i = 1; i <= n; i++){
			I >> a[i];
			a[i]++;
			b[i] = 0;
		}
		a[0] = 0;
		b[0] = 1;
		int e = 0;
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= k && j <= i; j++){
				if (a[i] > a[i-j] && b[i-j])
					b[i] = 1,
					e = i;
			}
		}
		cout << e << "\n";
		
	}
	//cin >> t;
	return 0;
}