# include <fstream>
# include <iostream>
# include <string>
# include <vector>
using namespace std;

void main ()
{
   ifstream in ("LADDER.IN");
   in.sync_with_stdio(false);
	int n;
    in>>n;
	for(int i=0; i<n; i++)
	{	int mass[100100];
		memset(mass,0,100100*sizeof(mass[0]));
	    int dp[100100];
		memset(dp,0,100100*sizeof(dp[0]));
		
		int p,k;
		in>>p>>k;
		for(int j=0; j<p; j++)
		{
			in>>mass[j];
		}
		 
		for(int j=0; j<k; j++)
			dp[j]=1;
		for(int j=k; j<p; j++)
		{
			for(int t=j; t>=0; t--)
			{
				if(dp[t]==1 && mass[j]>mass[t])
				{
					dp[j]=1;
					break;
				}
				if(j-t==k)
				{
					break;
				}
				
			}
		}
		int last=0;
		for(int j=0; j<p; j++)
			if(dp[j]==1)
				last=j;
		cout<<last+1<<endl;
	}
	//system("pause");
}
