# include <iostream>
# include <vector>
# include <cstdio>
# include <algorithm>
# include <cmath>
# include <set>
using namespace std;
int n,k;
vector <long long> d;
vector <char> f;
int main(){
	freopen("LADDER.IN", "r", stdin);
	int T;
	cin>>T;
	int max1;
	while(T--){
		cin>>n>>k;
		d.assign(n,0);
		f.assign(n,0);
		max1=k-1;
		for(int p=0;p<n;p++)
			cin>>d[p];
		for(int j=0;j<k;j++)
			f[j]=1;
		for(int u=0;u<n;u++)
			if(f[u]==1)
				for(int y=u+1;y<min(n,u+k+1);y++)
					if(d[u]<d[y]) {f[y]=1;if(y>max1) max1=y;};
cout<<max1+1<<endl;
	}
	
}
/*
2
5 2
4 4 3 1 4
5 3 
4 4 3 1 4
*/