import java.util.TreeMap;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;


public class StandingsBrute {
    public static void main(String[] args) {
        TreeMap<String, Integer> wins = new TreeMap<String, Integer>();
        TreeMap<String, Integer> losses = new TreeMap<String, Integer>();

        Scanner input = new Scanner(System.in);

        String team1 = input.next();
        int score1 = input.nextInt();
        String team2 = input.next();
        int score2 = input.nextInt();

        int numGames = 0;
        while (score1 >= 0 || score2 >= 0) {
            if (!wins.containsKey(team1)) {
                wins.put(team1, 0);
                losses.put(team1, 0);
            }

            if (!wins.containsKey(team2)) {
                wins.put(team2, 0);
                losses.put(team2, 0);
            }

            if (score1 > score2) {
                wins.put(team1, wins.get(team1)+1);
                losses.put(team2, losses.get(team2)+1);
            }
            else {
                wins.put(team2, wins.get(team2)+1);
                losses.put(team1, losses.get(team1)+1);
            }

            numGames++;

            team1 = input.next();
            score1 = input.nextInt();
            team2 = input.next();
            score2 = input.nextInt();
        }

        for (int i = numGames; i >= 0; i--) {
            for (String s : wins.keySet()) {
                int numWins = wins.get(s);
                if (numWins == i) {
                    System.out.println(s + " " + wins.get(s) + "-" + losses.get(s));
                }
            }
        }
        System.out.println("DONE");
    }
}
