#include #include #include #include #include #include #include using namespace std; string A, B; map > M; set S; vector V; bool compare(string A, string B) { if (M[A].first != M[B].first) return M[A].first > M[B].first; if (M[A].second != M[B].second) return M[A].second > M[B].second; return A < B; } int main() { cin.sync_with_stdio(false); for (int i = 1, g1, g2; i <= 6; ++i) { cin >> A >> B >> g1 >> g2; M[A].second += g1; M[B].second += g2; if (g1 < g2) M[B].first += 3; else if (g1 > g2) M[A].first += 3; else if (g1 == g2) { ++M[A].first; ++M[B].first; } S.insert(A); S.insert(B); } for (auto it = S.begin(); it != S.end(); ++it) V.push_back(*it); sort(V.begin(), V.end(), compare); for (auto it = V.begin(); it != V.end(); ++it) cout << *it << '\n'; }