import java.io.File;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * User: student
 * Date: 10.11.13
 * Time: 13:20
 * To change this template use File | Settings | File Templates.
 */
public class F {
    static int N, K;
    static int[] stairs;

    static Map<Integer, Integer> map;

    public static int solve(int start)
    {
        Integer integer = map.get(start);
        if (integer != null) return integer;

        int res = start;
        for (int cur = start + 1; cur < Math.min(start + K + 1, N + 1); cur++) {
            if (stairs[start] < stairs[cur]) {
                res = Math.max(res, solve(cur));
            }
        }

        map.put(start, res);

        return res;
    }

    public static void main(String[] args) throws FileNotFoundException {
        Scanner scanner = new Scanner(new File("LADDER.IN"));

        int T = scanner.nextInt();

        for (int i = 0; i < T; i++) {
            map = new HashMap<Integer, Integer>();

            N = scanner.nextInt();
            K = scanner.nextInt();

            stairs = new int[N+1];

            stairs[0] = -1;

            for (int j = 1; j <= N; j++) {
                stairs[j] = scanner.nextInt();
            }

            System.out.println(solve(0));
        }
    }
}
