// Arup Guha
// 12/3/2017
// Solution to 2017 NCPC Problem B: Best Relay Team

import java.util.*;

public class b {

	public static void main(String[] args) {

		// Get data.
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		runner[] list = new runner[n];
		for (int i=0; i<n; i++) {
			String s = stdin.next();
			double t1 = stdin.nextDouble();
			double t2 = stdin.nextDouble();
			list[i] = new runner(s, t1, t2);
		}

		// Sort it.
		Arrays.sort(list);

		// Safe upper bound.
		double res = 100;

		// Will store the team here.
		ArrayList<Integer> team = null;

		// Try each runner as the first leg runner.
		for (int i=0; i<n; i++) {

			// Build this team off starting runner i.
			double tmp = list[i].start;
			ArrayList<Integer> thisTeam = new ArrayList<Integer>();
			thisTeam.add(i);

			// Add the rest.
			for (int j=0; thisTeam.size()<4; j++) {
				if (j==i) continue;
				thisTeam.add(j);
				tmp += list[j].last;
			}

			// A better team.
			if (tmp < res-1e-9) {
				res = tmp;
				team = thisTeam;
			}
		}

		// Output the result.
		System.out.printf("%.2f\n", res);
		for (int i=0; i<4; i++)
			System.out.println(list[team.get(i)].name);
	}
}

// Make runner sort by running speed on last leg.
class runner implements Comparable<runner> {

	public String name;
	public double start;
	public double last;

	public runner(String n, double s, double l) {
		name = n;
		start = s;
		last = l;
	}

	public int compareTo(runner other) {
		if (this.last < other.last-1e-9) return -1;
		if (this.last > other.last+1e-9) return 1;
		return 0;
	}
}