import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class prog {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		ArrayList<String[]> games = new ArrayList<>();
		HashMap<String, Integer> results = new HashMap<>();
		HashMap<String, Integer> goals = new HashMap<>();
		int firstTeamGoals = 0;
		int secondTeamGoals = 0;
		String firstTeam;
		String secondTeam;
		for (int i = 0; i < 6; i++) {
			
			String s=scan.nextLine();
			games.add(s.split(" "));
			
			if (!results.containsKey(games.get(i)[0])) {
				results.put(games.get(i)[0], 0);
				goals.put(games.get(i)[0], 0);

			}
			if (!results.containsKey(games.get(i)[1])) {
				results.put(games.get(i)[1], 0);
				goals.put(games.get(i)[1], 0);
			}
		}

		for (int i = 0; i < 6; i++) {
			firstTeamGoals = Integer.parseInt(games.get(i)[2]);
			secondTeamGoals = Integer.parseInt(games.get(i)[3]);
			firstTeam = games.get(i)[0];
			secondTeam = games.get(i)[1];
			goals.put(firstTeam, goals.get(firstTeam) + firstTeamGoals);
			goals.put(secondTeam, goals.get(secondTeam) + secondTeamGoals);
			if (firstTeamGoals > secondTeamGoals) {
				results.put(firstTeam, results.get(firstTeam) + 3);
			}
			if (firstTeamGoals < secondTeamGoals) {
				results.put(secondTeam, results.get(secondTeam) + 3);
			}
			if (firstTeamGoals == secondTeamGoals) {
				results.put(firstTeam, results.get(firstTeam) + 1);
				results.put(secondTeam, results.get(secondTeam) + 1);
			}
		}

		List<String> keys = new ArrayList(results.keySet());
		Collections.sort(keys);
		boolean flag = false;
		for (String s : results.keySet()) {
			for (String st : results.keySet()) {
				if (results.get(s) == results.get(st) && !s.equals(st)) {
					flag = true;
				}
			}
		}
		boolean sortFlag = true;
		while (sortFlag) {
			sortFlag = false;
			for (int i = 0; i < 3; i++) {
				if (results.get(keys.get(i)) < results.get(keys.get(i + 1))) {
					String temp = (String) keys.get(i);
					keys.set(i, keys.get(i + 1));
					keys.set(i + 1, temp);
					sortFlag = true;
				}
				if (results.get(keys.get(i)) == results.get(keys.get(i + 1))) {
					if (goals.get(keys.get(i)) < goals
							.get(keys.get(i + 1))) {
						String temp = (String) keys.get(i);
						keys.set(i, keys.get(i + 1));
						keys.set(i + 1, temp);
						sortFlag = true;
					}
				}

			}
		}
		for(int i=0;i<4;i++){
			System.out.println(keys.get(i));
		}

	}

}