import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

class Pair {
	
	public Pair(String name) {
		a = b = 0;
		this.name = name;
	}
	
	public String name;
	public int a, b;
	
	@Override
	public String toString() {
		return name;
	}
}

public class prog {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		Map<String, Pair> map = new HashMap<String, Pair>();
		for (int i = 0; i < 6; i++) {
			String line = scanner.nextLine();
			String[] tokens = line.split("\\ ");
			
			Pair t1 = map.get(tokens[0]);
			Pair t2 = map.get(tokens[1]);
			
			if (t1 == null) {
				t1 = new Pair(tokens[0]);
				map.put(tokens[0], t1);
			}
			
			if (t2 == null) {
				t2 = new Pair(tokens[1]);
				map.put(tokens[1], t2);
			}
			
			int g1 = Integer.parseInt(tokens[2]);
			int g2 = Integer.parseInt(tokens[3]);
			
			t1.b += g1;
			t2.b += g2;
			if (g1 < g2) {
				t2.a += 3;
			}
			else if (g1 == g2) {
				t1.a += 1;
				t2.a += 1;
			}
			else {
				t1.a += 3;
			}
		}
		
		List<Pair> values = new ArrayList<Pair>(map.values());
		Collections.sort(values, new Dcomp());
		
		for (Pair p : values) {
			System.out.println(p);
		}
		
		scanner.close();
	}
}

class Dcomp implements Comparator<Pair> {

	@Override
	public int compare(Pair o1, Pair o2) {
		
		if (o1.a < o2.a) {
			return 1;
		}
		if (o1.a > o2.a) {
			return -1;
		}
		if (o1.b < o2.b) {
			return 1;
		}
		if (o1.b > o2.b) {
			return -1;
		}
		
		return o2.name.compareTo(o1.name);
	}
	
}