#include #include #include #include #include #include #include #include #include #include #include using namespace std; int tot, N, v1, v2, scor[10]; char sir1[100009], sir2[100009]; string name[4]; map < string , int > ever; string curr1, curr2, toate[10]; pair < int, string > fin[10]; void add (string p) { if (ever[p] == 0) { ever[p] = ++tot; toate[tot] = p; } } int main() { //freopen ("input", "r", stdin); //freopen ("output", "w", stdout); for (int i=1; i<=6; i++) { scanf ("%s %s %d %d\n", sir1, sir2, &v1, &v2); curr1 = sir1; curr2 = sir2; add (curr1); add (curr2); int p1, p2; p1 = ever[curr1]; p2 = ever[curr2]; if (v1 == v2) scor[p1] ++, scor[p2] ++; else if (v1 > v2) scor[p1] += 3; else scor[p2] += 3; } for (int i=1; i<=tot; i++) fin[i].second = toate[i], fin[i].first = -scor[i]; sort (fin + 1, fin + tot + 1); for (int i=1; i<=tot; i++) printf ("%s\n", fin[i].second.c_str()); return 0; }