#include <iostream>

using namespace std;
int t,n,k;
int a[100001];

int rec(int max,int v)
{
	int vv = v;
	int g;
	for (int i=v+1;i<=v+k && i<n;i++)
	{
		if (a[i] > max)
		{
			//cout << a[i] << " ";
			g = rec(a[i],i);
			
			if (g > vv)
				vv = g;
		}
	}
	return vv;
}

int main()
{
	freopen("LADDER.IN","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >> t;
	for (int i=0;i<t;i++)
	{
		cin >> n >> k;
		for (int j=0;j<n;j++)
		{
			cin >> a[j];
		}
		cout << rec(-1,-1) + 1 << endl;
	}
	return 0;
}