#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const int INF = 0x3f3f3f3f; const double EPS = 0.000000001; const double PI = 3.141592653589793; const long long LLINF = 99999999999999999LL; const int MAX_N = 100002; const int MOD = 1000000007; struct Team { string name; int points, goals; Team() { name.clear(); points = goals = 0; } }; int N, M, K; Team v[10]; map < string, int > Map; inline bool Team_cmp(Team a, Team b) { if(a.points > b.points) return 1; else if(a.points < b.points) return 0; if(a.goals > b.goals) return 1; else if(a.goals < b.goals) return 0; return a.name < b.name; } int main() { /* #ifndef ONLINE_JUDGE freopen("data.in", "r", stdin); #endif */ int n = 0; for(int i = 1; i <= 6; ++i) { string a, b; cin >> a; cin >> b; int x, y; cin >> x >> y; if(Map[a] == 0) { Map[a] = ++n; v[n].name = a; } if(Map[b] == 0) { Map[b] = ++n; v[n].name = b; } if(x > y) v[Map[a]].points += 3; else if(x < y) v[Map[b]].points += 3; else { v[Map[a]].points++; v[Map[b]].points++; } v[Map[a]].goals += x; v[Map[b]].goals += y; } sort(v + 1, v + n + 1, Team_cmp); for(int i = 1; i <= n; ++i) cout << v[i].name << "\n"; return 0; }