#include <iostream>
#include <fstream>
#include <string>
#include <vector>

using namespace std;

int MAX;

void rec(vector<int> v, int cur,int step)
{
	for(int i=cur+1; i<cur+1+step&&i<v.size();++i)
	{
		if(v[i]>v[cur])
		{
			if(MAX<i)
				MAX=i;
			rec(v,i,step);
		}
	}
	return;
}

int main()
{
	ifstream in("LADDER.IN");

	int n;
	in>>n;
	while(n--)
	{
		MAX=-1;
		int len,step;
		in>>len>>step;

		vector<int> v(len+1);
		v[0]=-1;
		for(int i=1;i<=len;++i)
		{
			in>>v[i];
		}
		rec(v,0,step);
		cout<<MAX<<endl;
	}
	return 0;
}
