Everyone knows that 2010 FIFA World Cup is being held in South Africa now. By the decision of BFA (Berland's Football Association) next World Cup will be held in Berland. BFA took the decision to change some World Cup regulations:

  * the final tournament features n teams (n is always even) 
  * the first n / 2 teams (according to the standings) come through to the knockout stage 
  * the standings are made on the following principle: for a victory a team gets 3 points, for a draw — 1 point, for a defeat — 0 points. In the first place, teams are ordered in the standings in decreasing order of their points; in the second place — in decreasing order of the difference between scored and missed goals; in the third place — in the decreasing order of scored goals 
  * it's written in Berland's Constitution that the previous regulation helps to order the teams without ambiguity. 



You are asked to write a program that, by the given list of the competing teams and the results of all the matches, will find the list of teams that managed to get through to the knockout stage.

Input

The first input line contains the only integer n (1 ≤ n ≤ 50) — amount of the teams, taking part in the final tournament of World Cup. The following n lines contain the names of these teams, a name is a string of lower-case and upper-case Latin letters, its length doesn't exceed 30 characters. The following n·(n - 1) / 2 lines describe the held matches in the format name1-name2 num1:num2, where name1, name2 — names of the teams; num1, num2 (0 ≤ num1, num2 ≤ 100) — amount of the goals, scored by the corresponding teams. Accuracy of the descriptions is guaranteed: there are no two team names coinciding accurate to the letters' case; there is no match, where a team plays with itself; each match is met in the descriptions only once.

Output

Output n / 2 lines — names of the teams, which managed to get through to the knockout stage in lexicographical order. Output each name in a separate line. No odd characters (including spaces) are allowed. It's guaranteed that the described regulations help to order the teams without ambiguity.

Examples

Input

4
A
B
C
D
A-B 1:1
A-C 2:2
A-D 1:0
B-C 1:0
B-D 0:3
C-D 0:3


Output

A
D


Input

2
a
A
a-A 2:1


Output

a


import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Problem19A {


    public static void main(String[] args) {
        Problem19A problemAplusB = new Problem19A();
        problemAplusB.inputParams.readInputParamsFromStream();
        problemAplusB.solve();
        problemAplusB.outputParams.writeOutputParamsToStream();
    }

    //input params
    public long length;
    public List<String> commandsNames;
    public List<String> commandsResults;

    //output params
    public List<String> commandsInFinal ;


    public class InputParams extends AbstractInputParams {
        @Override
        public void readInputParamsFromStream() {
            length = readInteger();
            commandsNames = readStringList(length);
            commandsResults = readStringList(length * (length - 1));
        }

    }

    public class OutputParams extends AbstractOutputParams {
        @Override
        public void writeOutputParamsToStream() {
            writeStringList(commandsInFinal);
        }
    }

    // Problem solution implementation
    public void solve() {

        Map<String, Long> commandsPoints = new HashMap<String, Long>();
        Map<String, Long> commandsGoalsDiff = new HashMap<String, Long>();
        Map<String, Long> commandsGoalsKicked = new HashMap<String, Long>();

        for (String command : commandsNames) {
            commandsPoints.put(command, new Long(0));
            commandsGoalsDiff.put(command, new Long(0));
            commandsGoalsKicked.put(command, new Long(0));
        }

        String firstCommandName = "";
        String secondCommandName = "";
        long firstCommandGoals, secondCommandGoals;

        Matcher matcher;
        boolean commands = true;
        Pattern commandPattern = Pattern.compile("^(\\w+)-(\\w+)$");
        Pattern resultPattern = Pattern.compile("^(\\d+):(\\d+)$");

        if (length > 2) {

            for (String commandsResult : commandsResults) {
                if (commands) {
                    matcher = commandPattern.matcher(commandsResult);
                    matcher.find();
                    firstCommandName = matcher.group(1);
                    secondCommandName = matcher.group(2);
                } else {
                    matcher = resultPattern.matcher(commandsResult);
                    matcher.find();

                    firstCommandGoals = Integer.parseInt(matcher.group(1));
                    secondCommandGoals = Integer.parseInt(matcher.group(2));

                    long firstCommandPointsBase = commandsPoints.get(firstCommandName);
                    long secondCommandPointsBase = commandsPoints.get(secondCommandName);
                    long firstCommandGoalsDiffBase = commandsGoalsDiff.get(firstCommandName);
                    long secondCommandGoalsDiffBase = commandsGoalsDiff.get(secondCommandName);
                    long firstCommandGoalsKickedBase = commandsGoalsKicked.get(firstCommandName);
                    long secondCommandGoalsKickedBase = commandsGoalsKicked.get(secondCommandName);

                    if (firstCommandGoals == secondCommandGoals) {
                        commandsPoints.put(firstCommandName, firstCommandPointsBase + 1);
                        commandsPoints.put(secondCommandName, secondCommandPointsBase + 1);
                    } else {
                        if (firstCommandGoals > secondCommandGoals) {
                            commandsPoints.put(firstCommandName, firstCommandPointsBase + 3);
                            commandsPoints.put(secondCommandName, secondCommandPointsBase + 0);
                        } else {
                            commandsPoints.put(firstCommandName, firstCommandPointsBase + 0);
                            commandsPoints.put(secondCommandName, secondCommandPointsBase + 3);
                        }
                    }

                    commandsGoalsDiff.put(firstCommandName, firstCommandGoalsDiffBase + firstCommandGoals - secondCommandGoals);
                    commandsGoalsDiff.put(secondCommandName, secondCommandGoalsDiffBase + secondCommandGoals -  firstCommandGoals);
                    commandsGoalsKicked.put(firstCommandName, firstCommandGoalsKickedBase + firstCommandGoals);
                    commandsGoalsKicked.put(secondCommandName, secondCommandGoalsKickedBase + secondCommandGoals);

                }
                commands = !commands;
            }
        }

        commandsInFinal = (List<String>) ((ArrayList<String>) commandsNames).clone();

        commandsInFinal.sort(new Comparator<String>() {
            public int compare(String firstCommandName, String secondCommandName) {
                long firstCommandPoints = commandsPoints.get(firstCommandName);
                long secondCommandPoints = commandsPoints.get(secondCommandName);
                long firstCommandGoalsDiff = commandsGoalsDiff.get(firstCommandName);
                long secondCommandGoalsDiff = commandsGoalsDiff.get(secondCommandName);
                long firstCommandGoalsKicked = commandsGoalsKicked.get(firstCommandName);
                long secondCommandGoalsKicked = commandsGoalsKicked.get(secondCommandName);


                if (firstCommandPoints > secondCommandPoints) {
                    return -1;
                }

                if (firstCommandPoints < secondCommandPoints) {
                    return 1;
                }

                if (firstCommandGoalsDiff > secondCommandGoalsDiff) {
                    return -1;
                }

                if (firstCommandGoalsDiff < secondCommandGoalsDiff) {
                    return 1;
                }

                if (firstCommandGoalsKicked > secondCommandGoalsKicked) {
                    return -1;
                }

                if (firstCommandGoalsKicked < secondCommandGoalsKicked) {
                    return 1;
                }

                return 0;
            }



        });

        commandsInFinal = commandsInFinal.subList(0, (int) length/2);

        commandsInFinal.sort(new Comparator<String>() {
            public int compare(String firstCommandName, String secondCommandName) {
                return firstCommandName.compareTo(secondCommandName);
            }
        });



    }





































    //Problem input/output classes

    abstract class AbstractParams {


        protected Scanner inputScanner = new Scanner(System.in);

        protected Long readInteger() {
            if (inputScanner.hasNextLong()) {
                return inputScanner.nextLong();
            } else {
                throw new IllegalArgumentException();
            }
        }

        protected List<String> readStringList(Long n) {
            List<String> stringList = new ArrayList<String>();
            for (int i = 0; i < n; i++) {
                String string = readString();
                stringList.add(string);
            }
            return stringList;
        }


        protected String readString () {
            return inputScanner.next();
        }
    }

    abstract class AbstractInputParams extends AbstractParams{
        abstract public void readInputParamsFromStream();

        void writeInt(Integer i) {
            System.out.print(i);
            System.out.print(" ");
        }
    }

    abstract class AbstractOutputParams extends AbstractParams {
        abstract public void writeOutputParamsToStream();

        void writeInt(Integer i) {
            System.out.print(i);
            System.out.print(" ");
        }

        void writeString(String string) {
            System.out.print(string);
            System.out.print(" ");
        }

        void writeStringList(List<String> stringList) {
            for (String string : stringList) {
                writeString(string);
            }
        }

    }

    InputParams inputParams = new InputParams();
    OutputParams outputParams = new OutputParams();
}

