#include <iostream>
#include <vector>
#include <cstring>
#include <bitset>
#include <set>
#include <deque>
#include <queue>
#include <iomanip>
#include <map>
#include <algorithm>
#include <cmath>
#include <stack>
#include <sstream>
#include <functional>
#include <utility>
#include <cstdio>

using namespace std;

#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define int64 unsigned long long

map<string,pair<int,int> > H;


int main(){

    for(int i = 1;i <= 6; i++){
        string s1,s2;
        int g1,g2;
        cin >> s1 >> s2 >> g1 >> g2;
        int p1=0 ,p2=0;
        if(g1 > g2)
            p1 = 3;
        else if(g1 < g2)
            p2 = 3;
        else p1 = p2 = 1;
        if(H.find(s1) == H.end()){
            H[s1] = make_pair(p1,g1);
        }
        else H[s1].first += p1,H[s1].second += g1;

        if(H.find(s2) == H.end()){
            H[s2] = make_pair(p2,g2);
        }
        else H[s2].first += p2,H[s2].second += g2;
    }

    map<string,pair<int,int> >::iterator it,best;
    while(!H.empty()){
        it = H.begin();
        best = it;
        for(; it != H.end(); it++){
            if(best->second.first < it->second.first){
                best = it;
                continue;
            }
            else if(best->second.first == it->second.first && best->second.second < it->second.second){
                best = it;
                continue;
            }
            if(best->second.first == it->second.first && best->second.second == it->second.second && best->first > it->first){
                best = it;
                continue;
            }
        }
        cout << best->first << "\n";
        H.erase(best);
    }

}