// Задача "Оптимизация сепарабельной функции"
// 12-ая Интернет-олимпиада сезона 2006-2007, базовый уровень
// Автор условия: Федор Царев, tsarev@rain.ifmo.ru
// Автор решения: Федор Царев, tsarev@rain.ifmo.ru

import java.io.*;
import java.util.*;

public class optimize_ft implements Runnable {

	private Scanner in;
	private PrintWriter out;

	private final static int MAXN = 1000;
	private final static double EPS = 1e-9;

	private void myAssert(boolean e, String message) {
		if (!e) {
			throw new Error("Assertion failure!!! " + message);
		}
	}


	private void solve() throws IOException {
		int n = in.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		double[] p = new double[n];
		double[] q = new double[n];
		double[] r = new double[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
			b[i] = in.nextInt();
			myAssert(Math.abs(a[i]) <= 1000, "|a[i]| > 1000");
			myAssert(Math.abs(b[i]) <= 1000, "|b[i]| > 1000");
			myAssert(a[i] <= b[i], "a[i] > b[i]");
			p[i] = in.nextInt();
			q[i] = in.nextInt();
			r[i] = in.nextInt();
			myAssert(Math.abs(p[i]) <= 10, "|p[i]| > 10");
			myAssert(Math.abs(q[i]) <= 10, "|q[i]| > 10");
			myAssert(Math.abs(r[i]) <= 10, "|r[i]| > 10");
			myAssert(Math.abs(p[i]) > EPS, "p[i] == 0");
		}

		double ans = 0;
		double[] ansX = new double[n];

		for (int i = 0; i < n; i++) {
			double xv = -q[i] / (2 * p[i]);
			ArrayList<Double> toCheck = new ArrayList<Double>();
			toCheck.add(1.0 * a[i]);
			toCheck.add(1.0 * b[i]);
			if (a[i] <= xv && xv <= b[i]) {
				toCheck.add(xv);								
			}
			double cur = 1e20;
			double curX = 1e20;
			for (Double xi : toCheck) {
				double val = p[i] * xi * xi + q[i] * xi + r[i];
				if (val < cur) {
					cur = val;
					curX = xi;
				}
			}
			ans += cur;
			ansX[i] = curX;
		}

		out.println(ans);
		for (int i = 0; i < n; i++) {
			if (i > 0) {
				out.print(" ");
			}
			out.print(ansX[i]);
		}
		out.println();

	}
    
	public void run() {
		try {
			solve();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			out.close();
		}
	}
	
	private optimize_ft(String name) {
		try {
			Locale.setDefault(Locale.US);
			in = new Scanner(new File(name + ".in"));
			out = new PrintWriter(new FileWriter(name + ".out"));	
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(239);
		}
	}

	public static void main(String[] args) {
		(new Thread(new optimize_ft("optimize"))).start();
	}
}
