// Arup Guha
// 11/20/2013
// Solution to 2013 Pacific Northwest Problem A: Assignments.
import java.util.*;

public class a {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Go through each case.
		for (int loop=0; loop<numCases; loop++) {

			int n = stdin.nextInt();
			int d = stdin.nextInt();
			int cnt = 0;
			for (int i=0; i<n; i++) {

				// Get data for this ship.
				int speed = stdin.nextInt();
				int fuel = stdin.nextInt();
				int fuelPerHr = stdin.nextInt();

				// Can't get there.
				if (fuelPerHr*d > fuel*speed) continue;

				// This one can make it.
				cnt++;
			}

			System.out.println(cnt);
		}
	}
}