import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Scanner;
import java.util.ArrayList;

public class Penguins
{
	public static void main(String args[])
	{
		new Penguins();
	}

	ArrayList<Ice> ices;
	double bird_jump;

	public Penguins()
	{
		Scanner s=new Scanner(System.in);

		int cases=s.nextInt();
		for(int c=0; c<cases; c++)
		{
			ices=new ArrayList<Ice>();
			int ice_count;
			int bird_count=0;

			ice_count=s.nextInt();
			bird_jump=s.nextDouble();
			for(int i=0; i<ice_count; i++)
			{
				Ice I=new Ice(s);
				ices.add(I);
				bird_count += I.birds;
			}

			for(int i=0; i<ice_count; i++)
			for(int j=0; j<ice_count; j++)
			{
				if (i!=j)
				{
					ices.get(i).maybeAddConnect(j);
				}
			}

			TreeMap<String, FlowNode> flow_graph=new TreeMap<String, FlowNode>();

			FlowNode src_node=new FlowNode();
			flow_graph.put("source", src_node);

			for(int i=0; i<ice_count; i++)
			{
				Ice I=ices.get(i);
				FlowNode n=new FlowNode();
				FlowNode n_air=new FlowNode();
				
				n.addOutConnect("air_" + i, 0, I.max_out);

				for(Integer j : I.connects_to)
				{
					n_air.addOutConnect("" + j, 0, Integer.MAX_VALUE);
				}

				if (I.birds > 0)
				{
					src_node.addOutConnect("" + i, 0, I.birds);
				}

				flow_graph.put("" + i, n);
				flow_graph.put("air_" + i, n_air);

			}

			boolean found_one=false;
			for(int i=0; i<ice_count; i++)
			{
				
				int out = MaxFlow.getMaxFlow(flow_graph, "source", "" + i, bird_count);
				if (out == bird_count)
				{
					System.out.print("" + i + " ");
					found_one=true;
				}
			}
			if (!found_one)
			{
				System.out.print("-1");
			}
			System.out.println();



		}
		


	}

	class Ice
	{
		double x;
		double y;
		int max_out;
		int birds;

		TreeSet<Integer> connects_to;

		public Ice(Scanner s)
		{
			connects_to=new TreeSet<Integer>();

			x=s.nextDouble();
			y=s.nextDouble();
			birds=s.nextInt();
			max_out=s.nextInt();

		}

		void maybeAddConnect(int n)
		{
			Ice other = ices.get(n);
			double delta_x = x - other.x;
			double delta_y = y - other.y;
			double dist = Math.sqrt( delta_x * delta_x + delta_y * delta_y);

			if (dist <= bird_jump)
			{
				connects_to.add(n);
			}

		}

	}

}
