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

using namespace std;

int main()
{
	ifstream in("LADDER.IN");
	int t;
	in>>t;
	for (int z=0;z<t;z++)
	{
		int n,k;
		in>>n>>k;
		vector<int> v(n);
		for (int i=0;i<n;i++) in>>v[i];
		int h=-1;
		int y=-1;
		while(true)
		{
			int max=2147483647;
			int g=0;
			int ff=0;
			for (int b=1;b<=k;b++)
			{
				if (h+b>=n) {ff=1;break;}
				if(v[h+b]<=max && y<v[b+h])
				{
					max=v[h+b];
					g=b;
				}
			}
			if (h+g>=n) break;
			if (g==0) break;
			y=v[h+g];
			h=h+g;
		}
		cout<<h+1<<endl;
	}
	return 0;
}