var t: text;
var t2,max,i,j,n,k,l: longint;
   a : array[0..100001] of longint;
   may : array[0..100001] of boolean;
begin
        max := 0;
        assign(t,'ladder.in');
        reset(t);
        readln(t,t2);
        for i := 1 to t2 do begin
                readln(t,n,k);
               for j := 1 to n do begin
                   read(t,a[j]);
               end;
               a[0] := 0;

               may[0] := true;
               for j := 1 to n do begin

                  for l := 1 to k do begin
                    if (j-l >= 0)
                    then if ((a[j] > a[j-l])and(may[j-l])) then begin
                        may[j] := true;
                        max := j;
                    end;
                  end;

               end;

writeln(max);


               readln(t);




        end;

        close(t);

end.