
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;
import java.util.TreeSet;


public class Solution {

 public static void main(String[] args) throws Exception {
  Solution main = new Solution();
  main.run();
  System.exit(0);
 }

 public void run() throws Exception {
  Scanner scan = new Scanner(new FileReader("bus.in"));
  //PrintWriter out = new PrintWriter("bus.out");
  PrintWriter out = new PrintWriter(System.out);
  
  
  int test = scan.nextInt();
  
  int[] D = new int[1010];
  int[] L = new int[1010];
  int[] H = new int[1010];
  
  for(int t=0; t<test; t++)
  {
	  int N, M;
	  N = scan.nextInt();
	  M = scan.nextInt();
		
	  TreeSet<Integer> speeds = new TreeSet<Integer>();
	  speeds.add(M);

		for (int i = 0;i < N;i++)
		{
			D[i] = scan.nextInt();
			L[i] = scan.nextInt();
			H[i] = scan.nextInt();
			if (L[i] < M)
				speeds.add(L[i]);
		}

		double lowestTime = 1000000000;
		int maxSpeed = 0;
	
		Iterator<Integer> iter = speeds.iterator();
		while(iter.hasNext())
		{
			Integer s = iter.next();
			double curTime = 0;
			
			for (int i = 0;i < N;i++)
			{
				curTime += D[i]*1.0 / s + (s > L[i] ? H[i] : 0);
			}

			if (s > maxSpeed && (curTime < lowestTime + 0.0001))
			{
				lowestTime = curTime;
				maxSpeed = s;
			}
		}
		out.println(maxSpeed);
  
  }  
  out.close();
  
 }
}