import java.util.*;
import java.awt.Point;

public class paretooptimal_AN {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int T = s.nextInt();
    for (int tc = 0; tc < T; tc++) {
      int n = s.nextInt(), k = s.nextInt();
      Point[] input = new Point[n];
      Point[] shadow = new Point[2 * n];
      for (int i = 0; i < n; i++) {
        input[i] = new Point(s.nextInt(), s.nextInt());
        shadow[2 * i] = new Point(input[i].x - k, input[i].y);
        shadow[2 * i + 1] = new Point(input[i].x, input[i].y - k);
      }

      Arrays.sort(shadow, Comparator.comparing(Point::getX).thenComparing(Point::getY));
      List<Point> envelope = new ArrayList<>();
      envelope.add(shadow[2 * n - 1]);
      for (int i = 2 * n - 2; i >= 0; i--) {
        if (shadow[i].y > envelope.getLast().y) envelope.add(shadow[i]);
      }

      TreeMap<Point, Integer> sortedInput = new TreeMap<>(Comparator.comparing(Point::getX).thenComparing(Point::getY));
      for (int i = 0; i < n; i++) {
        sortedInput.put(input[i], i + 1);
      }
      Set<Integer> output = new TreeSet<>();
      int cursor = 0;
      int wall = envelope.get(cursor).x;
      int floor = Integer.MIN_VALUE;
      for (var entry : sortedInput.descendingMap().entrySet()) {
        Point p = entry.getKey();
        while (p.x <= wall) {
          floor = envelope.get(cursor).y;
          cursor++;
          if (cursor < envelope.size()) {
            wall = envelope.get(cursor).x;
          } else {
            wall = Integer.MIN_VALUE;
          }
        }
        if (p.y > floor) output.add(entry.getValue());
      }
      
      System.out.println(output.size());
      for (int i : output) {
        System.out.print(i + " ");
      }
      System.out.println();
    }
  }
}
