public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder out = new StringBuilder();
		int nCases = Integer.parseInt(in.readLine().trim());
		for (int nCase = 0; nCase < nCases; nCase++) {
			in.readLine();
			if (nCase != 0)
				out.append('\n');
			int n = Integer.parseInt(in.readLine().trim());
			ArrayList<P> all = new ArrayList<>();
			TreeSet<Double> set = new TreeSet<>();
			double min = oo, max = -oo;
			for (int i = 0; i < n; i++) {
				double[] s = readDoubles(in.readLine());
				if (s[0] > s[2]) {
					double aux = s[0];
					s[0] = s[2];
					s[2] = aux;
					aux = s[1];
					s[1] = s[3];
					s[3] = aux;
				}
				all.add(new P(s[0], s[4], false));
				all.add(new P(s[2] + eps, 1 / s[4], true));
				set.add(s[0]);
				set.add(s[2]);
				min = Math.min(min, s[0]);
				max = Math.max(max, s[2]);
			}
			Collections.sort(all);
			StringBuilder out2 = new StringBuilder();
			out2.append(f(-oo, min, 1) + "\n");
			double mul = 1;
			int cnt = 2;
			for (int i = 0; i < all.size() - 1; i++) {
				P cur = all.get(i);
				mul *= cur.c;
				double next = set.higher(cur.x);
				if (!cur.d) 
					out2.append(f(cur.x, next, mul) + "\n");
				else
					out2.append(f(cur.x-eps, next, mul) + "\n");
				cnt++;
			}
			out2.append(f(max, oo, 1) + "\n");
			out.append(cnt + "\n" + out2);
		}
		System.out.print(out);
	}