// Arup Guha
// 2/12/2017
// Solution to 2017 FHSPS Problem: Frogger

import java.util.*;

public class frogger {

	public static int n;
	public static int anyaV;
	public static int prizeV;
	public static event[] intervals;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Process each case
		for (int loop=0; loop<numCases; loop++) {

			n = stdin.nextInt();
			anyaV = stdin.nextInt();
			prizeV = stdin.nextInt();
			intervals = new event[2*n];

			// Read in each prize - turn into equivalent x intervals.
			for (int i=0; i<n; i++) {
				int x = stdin.nextInt();
				int y = stdin.nextInt();
				int len = stdin.nextInt();
				int pts = stdin.nextInt();
				double[] xVals = equiv(x,y,len);
				intervals[2*i] = new event(xVals[0], pts);
				intervals[2*i+1] = new event(xVals[1], -pts);
			}

			//  Just sort them!
			Arrays.sort(intervals);

			// Just go through these events in order, from left ot right.
			// Right to left makes more sense, but either gets the same answer.
			int maxI = -1;
			int cur = 0, res = 0;
			for (int i=0; i<2*n; i++) {
				cur += intervals[i].pts;
				if (cur > res) maxI = i;
				res = Math.max(res, cur);
			}
			
			// To validate data - note: maxI will never equal 2n-1, so no AOOB occurs here.
			if (intervals[maxI+1].x - intervals[maxI].x <= .001)
				System.out.println("TOO CLOSE CALL");

			// Ta da!
			System.out.println(res);
		}
	}

	// This method is key, we can translate each prize to be an equivalent prize at
	// y = 0, but translating its movement in time.
	public static double[] equiv(int x, int y, int len) {
		double[] res = new double[2];
		res[0] = x + 1.0*prizeV*y/anyaV;
		res[1] = res[0] + len;
		return res;
	}
}

class event implements Comparable<event> {

	public double x;
	public int pts;

	public event(double myx, int myPts) {
		x = myx;
		pts = myPts;
	}

	public int compareTo(event other) {
		if (x < other.x-1e-9) return -1;
		if (x > other.x+1e-9) return 1;
		return other.pts - this.pts;
	}
}

